CentralCSP
APIAPI Keys

Create an API key

Creates a key for this workspace. The secret is in the key field of this response and is never shown again, so store it now. The key acts as you and can only reach this workspace. Give it an expiry when it is for a short-lived job, and an allowedIps list to pin it to known source addresses. Both are set at creation only, so revoke and reissue to change them.

Limited to 20 requests a minute for each workspace, after which it answers 429 with a Retry-After header.

Requires the admin role on the workspace and the api_keys plan feature.

POST
/v1/workspaces/{workspaceId}/api-keys

Authorization

headerAuthorizationBearer <JWT>

An OpenID Connect access token from signing in to CentralCSP, acting as the signed-in user.

Path Parameters

workspaceId*string

The workspace's id.

Request Body

application/json
  1. body
name*string

Display name, so you can tell your keys apart later.

Length1 <= length <= 255
expiresAt?string

When the key should stop working. Leave it out for a key that never expires.

Formatdate-time
allowedIps?array<>

IP addresses and CIDR ranges the key may be used from, IPv4 or IPv6, like 203.0.113.10 or 203.0.113.0/24. Requests from any other address are rejected. Leave it out for a key that works from anywhere. Set at creation only.

Itemsitems <= 50

Response Body

A new API key, including its secret.

application/json
  1. response
id*string

Unique identifier of the key.

workspaceId*string

The only workspace this key can reach.

name*string

Display name.

prefix*string

First characters of the key, enough to tell keys apart in a list.

createdBy*string

The user this key acts as when it makes requests.

createdByUser*|

Profile of the user who created the key.

allowedIps*array<string>|

IP addresses and CIDR ranges the key may be used from, or null when it works from anywhere.

expiresAt*|

When the key stops working, or null when it never does.

lastUsedAt*|

When the key was last used, or null if never. Can lag by up to a minute.

createdAt*string

When the key was created.

Formatdate-time
updatedAt*string

When the key was last changed.

Formatdate-time
key*string

The secret to send as a bearer token. This is the only time it is returned, so store it now.

Example Request
curl -X POST 'https://api.centralcsp.com/v1/workspaces/01936b7a-6f2e-7c31-9a4d-2f8e1c5b7d90/api-keys' \  -H 'Content-Type: application/json' \  -d '{  "name": "CI pipeline"}'
Example Response
{  "id": "string",  "workspaceId": "string",  "name": "CI pipeline",  "prefix": "ccsp_a1",  "createdBy": "string",  "createdByUser": {    "id": "string",    "email": "string",    "firstName": "string",    "lastName": "string",    "picture": "string"  },  "allowedIps": [    "string"  ],  "expiresAt": "2019-08-24T14:15:22Z",  "lastUsedAt": "2019-08-24T14:15:22Z",  "createdAt": "2019-08-24T14:15:22Z",  "updatedAt": "2019-08-24T14:15:22Z",  "key": "ccsp_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v"}