Create a webhook configuration

Coro provides webhook configuration to enable customers to receive real-time updates when specific events occur in a workspace. These webhooks are ideal for managed service providers (MSPs) to automate billing tasks such as updating invoices or tracking client usage changes. For more information about webhooks, see What are webhooks.

This guide describes how to create a webhook that is triggered when a new workspace is created:

  1. Request your authentication token.
  2. Create the webhook configuration.
  3. Receive webhook alerts.
  4. Manage your webhook configuration.

You can also create webhook configurations from the Coro console. For more information, see Creating and managing webhooks.

Request your authentication token

Make a POST request to the /oauth/token resource endpoint using your Client ID and Client Secret. Each token is valid for 24 hours.

The request should appear similar to:

curl -i -X POST \
  https://api.secure.coro.net/oauth/token \
  -H 'Content-Type: application/json' \
  -d '{
    "client_id": "2qDgzSrZxnUCs4jqmfdEP5MVkEmA3Uak",
    "client_secret": "9c9Dabz5nQT65LXfYt_61wxb9UssT7tpzTM-gVB4RJZB9gKDf1_TjO6o3eLcBaba",
    "audience": "https://api.secure.coro.net",
    "grant_type": "client_credentials"
  }'
const resp = await fetch(
  `https://api.secure.coro.net/oauth/token`,
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      client_id: '2qDgzSrZxnUCs4jqmfdEP5MVkEmA3Uak',
      client_secret: '9c9Dabz5nQT65LXfYt_61wxb9UssT7tpzTM-gVB4RJZB9gKDf1_TjO6o3eLcBaba',
      audience: 'https://api.secure.coro.net',
      grant_type: 'client_credentials'
    })
  }
);
const data = await resp.json();
console.log(data);

The following table describes the parameters in the request:

ParameterData typeDescriptionExampleRequired
client_idStringThe unique identifier for the client. This value is provided by Coro support.2qDgzSrZxnUCs4jqmfdEP5MVkEmA3Uakyes
client_secretStringThe secret for the client. This value is provided by Coro support.9c9Dabz5nQT65LXfYt_61wxb9UssT7tpzTM-gVB4RJZB9gKDf1_TjO6o3eLcBabayes
audienceStringThe URL for the Coro API server.
Options include: https://api.secure.coro.net, https://api.secure-ca.coro.net, https://api.secure-eu.coro.net
https://api.secure.coro.netyes
grant_typeStringThe method by which you want to request a bearer token for authentication. At this time, Coro only supports client_credentials.client_credentialsyes

A successful response appears similar to:

HTTP/1.1 200 OK
Content-Type: application/json
Date: {date}
X-Coro-Trace-Id: {trace-id}
Transfer-Encoding: chunked

{
  "access_token":"TRDNxdkVHYms0R2U1IiwiaWF0IjoxNjTRDNxdkVHYms0R2U1IiwiaWF0IjoxNjTRDNxdkVHYms0R2U1IiwiaWF0IjoxNjTRDNxdkVHYms0R2U1IiwiaWF0IjoxNjTRDNxdkVHYms0R2U1IiwiaWF0IjoxNj.dcukG0cw3eh4jqEMCwxZ2N3mziZ2hpFbv4--VYrXA3Q",
  "token_type":"Bearer",
  "expires_in":86400
  }

The following table describes the parameters in the response:

ParameterDescriptionExample
access_tokenThe access token used to access API resources.TRDNxdkVHYms0R2U1IiwiaWF0IjoxNjTRDNxdkVHYms0R2U1IiwiaWF0IjoxNjTRDNxdkVHYms0R2U1IiwiaWF0IjoxNjTRDNxdkVHYms0R2U1IiwiaWF0IjoxNjTRDNxdkVHYms0R2U1IiwiaWF0IjoxNj.dcukG0cw3eh4jqEMCwxZ2N3mziZ2hpFbv4--VYrXA3Q
token_typeThe type of token.Bearer
expires_inThe expiration time of the token, in seconds. Each token is valid for 24 hours.86400

Create the webhook configuration

Create a new webhook configuration. Make a POST request to the /settings/webhooks resource endpoint, and specify the workspace-created trigger.

The request should appear similar to:

curl -i -X POST \
  https://api.secure.coro.net/v1/settings/webhooks \
  -H 'Authorization: Bearer <access_token>' \
  -H 'Content-Type: application/json' \
  -H 'Workspace: company1Workspace' \
  -d '{"name": "Billing webhooks",
    "description": "Used for updating QuickBooks",
    "applyToAllDescendants": true,
    "url": "https://www.customer.example/quickbookwebhook",
    "secret": "supersecuresecret",
    "headers":{
        "Authorization": "Bearer YOUR_ACCESS_TOKEN",
        "Content-Type": "application/json"
        },
    "triggers": [
        "workspace-created"
        ],
    "status": "enabled"
    }'
const resp = await fetch(
  `https://api.secure.coro.net/v1/settings/webhooks`,
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'Billing webhooks',
      description: 'Used for updating QuickBooks',
      applyToAllDescendants: true,
      url: 'https://www.customer.example/quickbookwebhook',
      secret: 'supersecuresecret',
      headers: {
        X-Request-ID: 123e4567-e89b-12d3-a456-426614174000
      },
      triggers: [
        'workspace-created'
      ],
      status: 'enabled'
    })
  }
);

const data = await resp.json();
console.log(data);

The following table describes the parameters in the request:

FieldData typeDescriptionExampleRequired
WorkspaceStringThe workspace identifier, which isolates API requests inside the provided workspace scope.channelWorkspaceyes
nameStringThe name of the webhook.Billing webhooksNo
descriptionStringA longer description, if needed.Used to update QuickBooksNo
applyToAllDescendentsBooleanIf true, webhooks are sent for all descendants of this workspace. This is relevant for channel workspaces.trueYes
urlStringThe URL to which the webhook data will be sent.https://www.customer.example/quickbookwebhookYes
secretStringUsed to validate webhooks sent by Coro.supersecuresecretYes
headersObject of stringsA JSON object containing key-value pairs for any additional headers required by the receiving endpoint.X-Request-ID: 123e4567-e89b-12d3-a456-426614174000No
triggersArray of stringsA list of events that trigger the webhook.workspace-createdYes
statusStringThe current status of the webhook configuration. Options include enabled and disabled.enabledYes

A successful response appears similar to:

HTTP/1.1 201 Created
Content-Type: application/json
Date: {date}
X-Coro-Trace-Id: {trace-id}
Transfer-Encoding: chunked

{
    "id": "66b204f0c992d50b8b2f984c"
    "name": "Billing webhooks",
    "description": "Used for updating QuickBooks",
    "applyToAllDescendants": true,
    "url": "https://www.customer.example/quickbookwebhook",
    "secret": "supersecuresecret",
    "headers":{
        X-Request-ID: 123e4567-e89b-12d3-a456-426614174000
        },
    "triggers": [
        "workspace-created"
        ],
    "status": "enabled",
    "updated": 0
}

The following table describes the parameters in the response:

FieldData typeDescriptionExample
idStringThe unique identifier of the webhook configuration.66b204f0c992d50b8b2f984c
nameStringThe name of the webhook.Billing webhooks
descriptionStringA longer description, if needed.Used to update QuickBooks
applyToAllDescendentsBooleanIf true, webhooks are sent for all descendants of this workspace.true
urlStringThe URL to which the webhook data will be sent.https://www.customer.example/quickbookwebhook
secretStringUsed to validate webhooks sent by Coro. See Webhook security for more information.supersecuresecret
headersObject of stringsA JSON object containing key-value pairs for any additional headers required by the receiving endpoint.X-Request-ID: 123e4567-e89b-12d3-a456-426614174000
triggersArray of stringsA list of events that trigger the webhook.workspace-created
statusStringThe current status of the webhook configuration. Options include enabled and disabled.enabled
updatedStringThe timestamp of the webhook configuration, in UNIX format including milliseconds.1709856000000

Receive webhook alerts

Any time a new workspace is created, a webhook alert is sent to the specified URL. The alert appears similar to:

{
  "id": "12345",
  "timestamp": "1627670400000",
  "workspaceId": "workspace123",
  "type": "workspace-created",
  "data": {
    "companyName": "company1",
    "displayName": "company1",
    "domain": "The workspace domain",
    "type": "child",
    "maxProtectedUsers": "25",
    "notificationLevel": "parent",
    "parentWorkspaceId": "parentWorkspace",
    "adminEmails": "admin2@company1workspace.com",
    "workspaceCreationTime": "1641009600000"
    "subscriptionType": "initial"
    }
}
FieldData typeDescriptionExample
idThe unique identifier of the webhook.12345
timestampThe timestamp of the webhook, in UTC milliseconds.1627670400000
workspaceIdThe unique identifier of the workspace to which the webhook applies.workspace123
typeThe event which triggered the webhook.workspace-created
data > companyNamestringThe name of the company for which the workspace is created.company1
data > displayNamestringThe name displayed for the workspace from the user interface.company1
data > domainstringThe workspace domain.company1Workspace.com
data > typestringThe type of workspace being created.
Options include: regular - for individual companies; channel - for the MSP parent level; child - for MSP customers.
child
data > maxProtectedUsersstringThe maximum number of users allowed in the workspace.25
data > notificationLevelstringThe admin users who will receive notifications.
Options include: none, parent, all.
parent
data > parentworkspaceIdstringThe unique identifier of the parent workspace, if applicable.parentWorkspace
data > adminEmailsstringThe email addresses of all admin users associated with the workspace.admin2@company1workspace.com
data > workspaceCreationTimestringThe date the workspace was created, in UNIX format, including milliseconds.1641009600000
data > subscriptionTypestringThe type of subscription for the workspace.initial

Manage your webhook configuration

After creating a webhook configuration, you can view, update, or delete the configuration with GET, PUT, or DELETE requests to the /settings/webhooks/{id} resource endpoint. For more information about these calls, see the Coro API reference.