Skip to content

Commit 614a2e8

Browse files
authored
Subaccounts Pagination
1 parent 6a31b73 commit 614a2e8

File tree

1 file changed

+100
-5
lines changed

1 file changed

+100
-5
lines changed

content/api/subaccounts.apib

Lines changed: 100 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ description: Manage subaccounts, a way for service providers to provision and ma
44

55
# Group Subaccounts
66

7+
<Banner status="warning"><strong>Deprecation of non-paginated results</strong>: All results returned from the `GET /api/v1/subaccounts` endpoint will be [paginated](#header-pagination) by default starting March 2022. Set the`cursor` parameter to `initial` to test paginated results.</Banner>
8+
79
Subaccounts are a way for you to provision and manage senders separately from each other, and to provide assets and reporting data for each of them. This is useful for service providers who send on behalf of others or for a business that wants to separate their different streams of traffic. Learn more in our [subaccount guide](https://www.sparkpost.com/docs/user-guide/subaccounts/).
810

911
The following APIs have subaccount support:
@@ -43,6 +45,63 @@ When making POST, PUT, or DELETE requests without the `X-MSYS-SUBACCOUNT` header
4345

4446
<Banner status="info">`X-MSYS-SUBACCOUNT` is not required, but if provided, must be a number.</Banner>
4547

48+
### Pagination
49+
50+
The Subaccounts API supports pagination for queries with larger result sets. Pagination is done through the use of the `cursor` and `per_page` query parameters.
51+
The `per_page` query parameter sets the number of subaccounts to return in a single request, and supports a maximum value of 100.
52+
53+
Once you have the response, you then can use `links` to retrieve the URL for your next page, which will be prefilled with the appropriate value for the `cursor` query parameter,
54+
as well as any other filters you supplied with the original request.
55+
56+
If your result set is less than one page of data, then the `links` object will not have a `next` key.
57+
58+
+ Data Structure: Paginated Response
59+
+ results (array) - A page of subaccount objects that match the search parameters.
60+
+ total_count (number) - The total number of subaccounts that match the search parameters.
61+
+ links (object)
62+
+ next (string)
63+
A URL that can be used to retrieve the next page of results. Will be prefilled with the appropriate value for the `cursor` query parameter, as well as any other filters supplied with the original request.
64+
65+
+ Sample
66+
67+
{
68+
"results": [
69+
{
70+
"id": 1,
71+
"name": "Joe's Garage",
72+
"status": "active",
73+
"ip_pool": "my_ip_pool",
74+
"compliance_status": "active",
75+
"options": {
76+
"deliverability": true
77+
}
78+
},
79+
{
80+
"id": 2,
81+
"name": "SharkPost",
82+
"status": "active",
83+
"compliance_status": "active",
84+
"options": {
85+
"deliverability": true
86+
}
87+
88+
},
89+
{
90+
"id": 3,
91+
"name": "Dev Avocado",
92+
"status": "suspended",
93+
"compliance_status": "active",
94+
"options": {
95+
"deliverability": true
96+
}
97+
}
98+
],
99+
"total_count": 350,
100+
"links":{
101+
"next": "/api/v1/subaccounts?cursor=WzIxMCwyMTBd&per_page=3&sort_by=id"
102+
}
103+
}
104+
46105
### Subaccount object
47106

48107
+ Data Structure: Attributes
@@ -287,19 +346,55 @@ This endpoint only returns information about the subaccount, not the resources a
287346
}
288347
}
289348

290-
### List all Subaccounts [GET /v1/subaccounts{?option}]
349+
### List Subaccounts [GET /v1/subaccounts]
350+
351+
<Banner status="warning"><strong>Deprecation of non-paginated results</strong>: All results returned from the `GET /api/v1/subaccounts` endpoint will be [paginated](#header-pagination) by default starting March 2022. Set the`cursor` parameter to `initial` to test paginated results.</Banner>
352+
353+
Returns a list of your subaccounts. Passing certain query parameters will cause results to be [paginated](#header-pagination).
354+
355+
+ Parameters
356+
357+
+ option (enum[string], optional) - Filters subaccounts to those with the option enabled.
358+
+ Members
359+
+ `deliverability`
360+
361+
+ cursor (string, optional) - A cursor provided in the `links` object of a page of results, used to get the next page of results. Set this parameter to `initial` to retrieve the first page of results. Passing this parameter will cause results to be [paginated](#header-pagination).
291362

292-
Returns a list of your subaccounts.
363+
+ per_page (number, optional) - Limits the number of subaccounts that are returned in the `results` object. The maximum allowed value is 100. Passing this parameter will cause results to be [paginated](#header-pagination).
364+
+ Default: 25
365+
366+
+ sort_by (enum[string], optional) - Sorts results by the specified property. Passing this parameter will cause results to be [paginated](#header-pagination).
367+
+ Default: `created_at`
368+
+ Members
369+
+ `created_at`
370+
+ `updated_at`
371+
+ `id`
372+
+ `name`
373+
374+
+ order (enum[string], optional) - Returns subaccounts in the specified order based on the `sort_by` parameter. `asc` returns results in ascending order, `desc` returns results in descending order. Passing this parameter will cause results to be [paginated](#header-pagination).
375+
+ Default: `desc`
376+
+ Members
377+
+ `asc`
378+
+ `desc`
379+
380+
+ ip_pool (string, optional) - Returns only subaccounts that are assigned to the IP pool with the ID passed in this parameter. Passing this parameter will cause results to be [paginated](#header-pagination).
381+
382+
+ status (enum[string], optional) - Returns only subaccounts with the specified status. Passing this parameter will cause results to be [paginated](#header-pagination).
383+
+ Members
384+
+ `active`
385+
+ `suspended`
386+
+ `terminated`
387+
388+
+ name (string, optional) - Returns subaccounts whose name includes the string passed in the parameter. May return false positives. Passing this parameter will cause results to be [paginated](#header-pagination).
389+
390+
+ ids: `1,2,3,4` (string, optional) - Returns only subaccounts with the IDs included in the comma separated list in the parameter. Passing this parameter will cause results to be [paginated](#header-pagination).
293391

294392
+ Request
295393

296394
+ Headers
297395

298396
Authorization: 14ac5499cfdd2bb2859e4476d2e5b1d2bad079bf
299397
Accept: application/json
300-
+ Parameters
301-
302-
+ option (optional, string, `deliverability`) ... Filters subaccounts to those with the option enabled. The only valid value is currently `deliverability`.
303398

304399
+ Response 200 (application/json)
305400

0 commit comments

Comments
 (0)