Account Provisioning API
To manage their customer accounts, the Twilio SendGrid provides the Account Provisioning API for resellers. This API covers companies that have a formal reseller partnership with Twilio SendGrid.
You can access Twilio SendGrid sub-account functionality without becoming a reseller. If you require sub-account functionality, see the Twilio SendGrid Subusers feature available in the Pro and Premier plans.
- Reseller: The individual that owns an Account Provisioning API account.
- Customer account: An account that a reseller owns and manages through the API.
- Offering: An email package with a set of features.
To create and manage your customers' accounts, use the Account Provisioning API. The most common operations that a reseller performs include:
- Creating a customer account.
- Understanding account state.
- Managing customer account offerings.
- Managing customer IP addresses.
- Deactivating and removing account resources.
- Authenticating customers with single sign-on (SSO).
To learn more about the other Account Provisioning API operations, see the API reference documentation for each operation.
The Create Account operation requires a JSON request body containing a profile object and an array of offerings objects. To create a customer account, make a single POST operation. This request returns the unique Twilio SendGrid account ID for the created account.
| Component | Type | Necessity | Contents | API reference |
|---|---|---|---|---|
profile | object | Optional | Identity data for one customer with their first_name, last_name, and email. If the fields aren't provided, Twilio prompts the customer to enter this data at their first login. | API |
offerings | array | Required | Offering objects with its name, type, and quantity that define the features in the customer's account. These offerings depend on your agreement with Twilio SendGrid. | API |
To retrieve a list of all the offerings that you can assign to a customer account, use the List Offerings endpoint. Available offerings change infrequently. Rather than call the endpoint before each account creation or update, cache the List Offerings response. An account may start on any email offering at any price point. You can upgrade or downgrade an account immediately after account provisioning.
To create a customer account, write a JSON block that resembles the following:
1{2"profile": {3"first_name": "Jane",4"last_name": "Doe",5"company_name": "Cake or Pie Bakery",6"company_website": "www.example.com",7"email": "jdoe@example.com",8"phone": "+15555555555",9"timezone": "Asia/Tokyo"10},11"offerings": [12{13"name": "milne.ei.pro-100k.v1",14"type": "package",15"quantity": 116}17]18}
This request responds with a Twilio SendGrid account ID. All subsequent calls to the Account Provisioning API use this account ID. Record it in your database for future use.
1{2"account_id": "sg2a2bcd3ef4ab5c67d8efab91c01de2fa"3}
To create a new customer test account with Account Provisioning API, pass in the following custom header:
T-Test-Account: true
You can't allocate a dedicated IP address to a test account. This limits you to sending 100 email per day irrespective of the offerings used to create the account. You can't change non-test account that uses this custom header to a test account.
A customer accounts exist in one of five states, activated, deactivated, suspended, banned, or indeterminate*.
- To set the customer account state, make one
PUTrequest with one of these states. - To retrieve the customer account state, make one
GETrequest that returns the state for the account.
The following table shows the actions available to an account based on its state.
| Account state | activated | suspended | deactivated | banned |
|---|---|---|---|---|
| Can login | yes | yes | yes | no |
| Can requests mail messages | yes | yes | no | no |
| Can delivers mail messages | yes | no | no | no |
| Can removes subusers | no | no | no | yes |
| Can removes dedicated IP addresses | no | no | no | yes |
| Can deactivates API keys | no | no | no | yes |
* If you find an account in the indeterminate state, contact Twilio SendGrid support.
Once you create a customer account, you might need to upgrade or downgrade the account to a different offering. Beyond common email infrastructure offerings, your partner organization might offer "add-ons" features like Marketing Campaigns, Dedicated IP address Addresses, and Expert Services.
- To change an account's offerings, make one
PUTrequest with a JSON request body that contains anofferingsarray. - To remove offerings from an account, make one
PUTrequest that omits the offerings you want to remove from the update request.- In each request, pass all offerings you want to keep. Each
PUTrequest overwrites the existing offerings for the account.
- In each request, pass all offerings you want to keep. Each
- To get a list of all the offerings that you might assign to a customer account, use the List Offerings endpoint.
- To get a list of the offerings assigned to an individual customer account, use the Get Account Offerings endpoint.
Request payload example: Add package offering
1{2"offerings": [3{4"name": "milne.ei.pro-100k.v1",5"type": "package",6"quantity": 17}8]9}
Removes IP addresses from last added
When removing an IP address offering, the Account Provisioning API removes the most recently added IP address from the account. Email messages get spread evenly across all IP addresses. To remove a specific IP address, contact Twilio support.
The change offering request returns a list of the account's offerings. This list matches the response to subsequent Get Account Offerings requests.
To manage dedicated IP addresses for their customer accounts, resellers can use the IP address Provisioning API. To support your customer requirements, you can add, list, and remove IP addresses as needed.
The most common IP address provisioning operations that a reseller uses include:
- Add IP addresses to a customer account.
- List the IP addresses assigned to a customer account.
- Remove IP addresses from a customer account.
To add IP addresses to a customer account, make one POST request. This request provisions and assigns dedicated IP addresses to the specified customer account. This request requires a JSON payload with the quantity of IP addresses and the target region.
The request payload requires two parameters:
| Parameter | Purpose | Accepted values |
|---|---|---|
count | The number of IP addresses to provision. | Number between 1 and 10 |
region | The geographic region where the IP addresses should be provisioned. | us (United States), eu (Europe) |
All IP addresses in a single request must be from the same region. If you need IP addresses in multiple regions, you must make separate API calls for each region.
To add two IP addresses in the US region, include a JSON object that resembles the following:
{ "count": 2, "region": "us" }
The response returns an HTTP 201 Created status code along with the provisioned IP addresses and their region:
1{2"ips": [3"192.168.1.1",4"192.168.1.2"5],6"region": "us"7}
You can use the returned IP addresses immediately with the customer account.
To get a paginated list of all IP addresses associated with a customer account, use a GET operation. This operation returns the IP addresses as last added.
By default, the endpoint returns 10 results per request.
- To change the number of results returned, pass the
limitquery parameter. Each operation can include up to 5,000 results. - To paginate through results, pass the
offsetparameter. This gets set to the last IP address from the previous response.
The response includes an array of IP address objects, each containing the IP address and its region:
1{2"result": [3{4"ip": "174.0.2.1",5"region": "us"6},7{8"ip": "192.0.0.1",9"region": "eu"10}11],12"pages": {13"last": "192.0.0.1"14}15}
To remove IP addresses from a customer account with a single DELETE operation that includes a JSON payload.
- The payload contains an array of specific IP addresses.
- Each request can remove between one and 10 IP addresses.
- Specify each IP address in standard IPv4 notation.
To remove two specific IP addresses, include a JSON object payload that resembles the following:
{ "ips": [ "174.0.0.3", "192.0.0.1" ] }
A successful response returns a 204 No Content status code. This removes the IP addresses from the customer account.
When you remove an IP address from a customer account, this stops all email traffic that uses that IP address.
Before removing IP addresses to avoid service disruption, update your customer's sending configuration.
To set the account state to deactivated, use the Update Account State operation.
{ "state": "deactivated" }
To remove features such as Subusers and Dedicated IP addresses from a customer account, use the Update Account Offerings operation.
This example shows how to update the account with a free offerings payload.
1{2"offerings": [3{4"name": "milne.ei.free-100.v1",5"type": "package",6"quantity": 17}8]9}
Once you create a customer account, the reseller can trigger a login to the Twilio SendGrid console for the customer without a password.
To remove the need for a username and password, use the Account Provisioning SSO. The reseller can manage their customers' authentication credentials without sharing any data with Twilio. The redirect generated as part of this flow contains a one-time authorization code that logs the user into the Twilio SendGrid console.
- This one-time code lasts 60 seconds.
- You can use each code for login once.
- This blocks any type of man-in-the-middle or replay attack.
- SSO authenticates the customer as an Admin Teammate with all management permissions any aspect of the customer's account.
- Only the base Admin Teammate can authenticate using SSO.
- Neither teammates nor subusers can use SSO.
From there, set up API keys, create additional teammates or subusers, and configure their sender identity.
SAML SSO unsupported
The Account Provisioning API doesn't support the SAML-based SSO offering for customer accounts. All Teammates that belong to a customer account get authenticated with a username and password managed through Twilio SendGrid.