Subprojects via Bundles

To create subprojects via Bundles, you can either just send boolean true, or specify the name of the subproject and optionally add labels.

Subprojects can be added together with SMS Applications, Conversation Applications, or both, in which case the app(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.

Creating a subproject using boolean

The following code sample creates a subproject using the Provisioning API Bundles:

Copy
Copied
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',
        subproject: true,
    })
  );

  const data = await resp.json();
  return data;
}

If set to true, a subproject will be created under the provided project ID with default name from the root object.

If set to false, a subproject will not be created and instead all resources will be created under the project ID provided in the request.

Creating a subproject with custom name

The following code sample creates a subproject using the Provisioning API Bundles:

Copy
Copied
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',
        subproject: {
          name: 'Subproject name',
        },
    })
  );

  const data = await resp.json();
  return data;
}

Optionally labels can be attached to subproject. If provided, they must be an object with string keys and string values.

For example:

Copy
Copied
{
  "any-key": "string value"
}

If set to false or not provided, a subproject will not be created and instead all resources will be created under the project ID provided in the request.