To create SMS Applications via Bundles, you can either just send boolean true, or specify the name of the SMS Application.
SMS Applications can be added together with subprojects, and a Conversation Application, in which case the application(s) will be associated to the subproject.
Note that, for this guide, we provide node.js code samples. However, the principles apply to any language you use to make requests to the API.
The following code sample creates a subproject using the Provisioning API Bundles:
import fetch from 'node-fetch';
async function createSubproject() {
const resp = await fetch(
`https://provisioning.api.sinch.com/v1/projects/${PROJECT_ID}/bundles`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization:
'Basic ' +
Buffer.from(ACCESS_KEY + ':' + ACCESS_SECRET).toString('base64'),
},
body: JSON.stringify({
name: 'Small bundle example',
region: 'US',
smsApp: true,
})
}
);
const data = await resp.json();
return data;
}If set to true, an SMS Application will be created under the project or subproject specified, with the name of the root object. If neither this value or the name in the root is set, then the request will fail.
If set to false or left undefined, a SMS Application will not be created.
The following code sample creates a subproject using the Provisioning API Bundles:
import fetch from 'node-fetch';
async function createSubproject() {
const resp = await fetch(
`https://provisioning.api.sinch.com/v1/projects/${PROJECT_ID}/bundles`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization:
'Basic ' +
Buffer.from(ACCESS_KEY + ':' + ACCESS_SECRET).toString('base64'),
},
body: JSON.stringify({
name: 'Small bundle example',
region: 'US',
smsApp: {
name: 'SMS Application name',
},
})
}
);
const data = await resp.json();
return data;
}An SMS Application will be created under the project or subproject specified, with given name.
If set to false or left undefined, a SMS Application will not be created.
If you already have an SMS Application and want to link it to a new Conversation Application via a bundle, provide the SMS App ID:
import fetch from 'node-fetch';
async function linkExistingSmsApp() {
const resp = await fetch(
`https://provisioning.api.sinch.com/v1/projects/${PROJECT_ID}/bundles`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization:
'Basic ' +
Buffer.from(ACCESS_KEY + ':' + ACCESS_SECRET).toString('base64'),
},
body: JSON.stringify({
name: 'Link existing SMS app',
region: 'EU',
smsApp: {
smsAppId: 'your-existing-sms-app-id',
},
convApp: true,
}),
}
);
const data = await resp.json();
return data;
}The existing SMS App's region must match the bundle region. If it doesn't, the request will fail with SMS_APP_REGION_MISMATCH.
The bundle creation process is asynchronous. The response is returned immediately with the bundle's current state:
| State | Description |
|---|---|
IN_PROGRESS | Resources are being created and linked. The SMS channel is being activated on the Conversation App. |
DONE | All resources have been successfully created and the SMS channel is active on the Conversation App. |
FAILED | One or more steps failed during the process. |
Once the bundle is created, the following happens behind the scenes:
- The Conversation Application is created (or retrieved if you linked an existing one)
- The SMS Application is created (or retrieved if you linked an existing one)
- The SMS channel credentials are added to the Conversation Application
- The channel activation occurs asynchronously — the
smsChannelStatuson the Conversation App transitions fromPENDINGtoACTIVE
You can poll the bundle endpoint (GET /v1/projects/:projectId/bundles/:bundleId) to check the current state.
The following errors may be returned during bundle creation with an SMS Application:
| HTTP | Error Code | Message | When |
|---|---|---|---|
| 409 | SMS_APP_REGION_MISMATCH | SMS app region does not match the bundle region. | Linked SMS App's region doesn't match the bundle region |
| 404 | SMS_APP_NOT_FOUND | SmsApp not found. | The smsAppId provided doesn't exist in the project |
| 409 | SMS_APP_IS_ALREADY_LINKED_TO_CONVERSATION_APP | SmsApp is already linked to ConversationApp. | The SMS App is already connected to another Conversation App |
| 409 | SMS_APP_IS_ALREADY_IN_BUNDLES_PROCESS | SmsApp is already in Bundles process. | The SMS App is already part of another active bundle |
| 409 | MORE_THAN_ONE_SMS_APP | More than one SmsApp. | Multiple SMS Apps exist and the default one can't be determined |
| 404 | CONVERSATION_APP_NOT_FOUND | Conversation app not found. | The linked Conversation App doesn't exist in this region |
| 409 | CONVERSATION_APP_IS_ALREADY_CONNECTED_TO_SMS_APP | ConversationApp is already connected to SmsApp. | The Conversation App already has an SMS channel connected |