Create an API key for myself

​

Create a new API key for the current user.

Important: The API key will only be shown once in the response. Store it securely - it cannot be retrieved later.

Role options:

  • Omit roleId to inherit your current roles (sessions and inheriting keys only)
  • Provide a roleId for scoped permissions (e.g., read-only)
  • A request authenticated with a role-scoped API key must supply a roleId at or below that key's role; omitting it is refused with 403 API_KEY_ROLE_NOT_ALLOWED, since an inheriting key would carry the owner's full permissions.

Expiration options:

  • Use expiresInDays for fixed expiration (7, 30, 90, 180, 365)
  • Set expiresInDays to null for never-expiring keys

Body

required
application/json
  • Display name for the API key

  • Days until expiration (null = never expires)

  • Additional metadata to store with the key

  • Role to assign (null = inherit user's roles; not permitted when the caller is a role-scoped API key)

Responses

  • application/json
  • application/json
  • application/json
  • Cannot assign the specified role

Request Example for post/auth/api-keys/me
curl https://api.gpcn.com/v1/auth/api-keys/me \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: YOUR_SECRET_TOKEN' \
  --data '{
  "name": "My CI/CD Key",
  "roleId": "",
  "expiresInDays": 90,
  "metadata": {}
}'
{
  "success": true,
  "data": {
    "key": "string",
    "id": "string",
    "prefix": "string",
    "start": "string",
    "message": "string"
  }
}