Getting started

Note

This functionality is currently only available for selected accounts but will become more broadly available in the future.

To get started using the Access Keys Management API we need to create our first Access Key. This we need to do via the Sinch Customer Dashboard.

Once we have secured our first Access Key we can then use it to create additional keys or revoke access for existing keys.

Exchange your Key ID and Key Secret found in the Customer Dashboard for a bearer token (also known as the access_token).
Copy
Copied
$ curl https://auth.sinch.com/oauth2/token -d grant_type=client_credentials --user <key_id>:<key_secret>

{"access_token":"...","expires_in":3599,"scope":"","token_type":"bearer"}
Your access_token will be included in a successful response. The access token can be used as the bearer token in each call to the Access Key Management API.

The bearer token is valid for one hour.

Note:

You can generate multiple access token for a single Access Key and use them simultaneously.

Creating a new Access Key

Create a new access key by authenticating with an existing access key. Key ID and Secret are generated and returned. Once returned the first time, the secret cannot be viewed again. Ensure to save it somewhere secure for use.

Copy
Copied
$ curl https://account.api.sinch.com/v1/projects/{project_id}/accessKeys \
-H "Authorization: Bearer YOUR_access_token" \
-d '{
  "displayName": "My production Access key"
}'

{
  "accessKey": {
    "accessKeyId": "{accessKeyId}",
    "displayName": "My production Access key",
    "projectId": "{project_id}",
    "createTime": "2024-09-05T08:37:17.025Z",
    "updateTime": "2024-09-05T08:37:17.025Z",
  },
  "secret": "Q_qHBbB8Dfje..."
}
Note:

You can have a maximum of 10 keys per project.

Deleting an Access Key

Delete an existing Access Key. No new access tokens can be generated for this key. Existing access token might be valid for up to 1 minute.

Copy
Copied
$ curl -X DELETE -H "Authorization: Bearer YOUR_access_token" \
https://account.api.sinch.com/v1/projects/{project_id}/accessKeys/{accessKeyId}
Note:

Note: It is currently possible to delete the same Access Key that is used for the delete operation. This means it is possible to delete the last key. In this scenario a new key needs to be generated in the customer dashboard.

We'd love to hear from you!
Rate this content:
Still have a question?
 
Ask the community.