Skip to main content
POST
/
v1
/
api_keys
JavaScript
import Charcoal from '@charcoalhq/sdk';

const client = new Charcoal({
  apiKey: process.env['CHARCOAL_API_KEY'], // This is the default and can be omitted
});

const createAPIKeyResponse = await client.apiKeys.create({ name: 'x' });

console.log(createAPIKeyResponse.api_key);
{
  "api_key": {
    "id": "<string>",
    "name": "<string>",
    "key_prefix": "<string>",
    "key_suffix": "<string>",
    "created_by": "<string>",
    "created_at": "2023-11-07T05:31:56Z",
    "last_used_at": "2023-11-07T05:31:56Z"
  },
  "raw_key": "<string>"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
name
string
required

Human-readable name for the key.

Required string length: 1 - 255

Response

Successful response

Response from creating an API key. The raw_key field is only returned on creation and cannot be retrieved again — store it securely.

api_key
object
required
raw_key
string
required

The full API key. Only returned at creation time.