Skip to content

Create API key

POST
/api/v1/organizations/{orgId}/api-keys
curl --request POST \
--url http://localhost:3000/api/v1/organizations/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/api-keys \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <X-API-Key>' \
--data '{ "name": "Production CI/CD Key", "description": "Used by GitHub Actions for automated deployments", "permissions": [ "devices:read", "deployments:read", "deployments:write" ], "expiresAt": "2025-12-31T23:59:59Z" }'

Creates a new API key for programmatic access. The full key is only returned once on creation.

orgId
required
string format: uuid

Organization UUID

Media type application/json
object
name
required

Display name for the API key

string
>= 2 characters <= 100 characters
Example
Production CI/CD Key
description

Description of the API key purpose

string
<= 500 characters
Example
Used by GitHub Actions for automated deployments
permissions

List of permission keys to grant to this API key

Array<string>
Example
[
"devices:read",
"deployments:read",
"deployments:write"
]
expiresAt

Expiration date for the API key in ISO 8601 format

string format: date-time
Example
2025-12-31T23:59:59Z

API key created successfully. Store the key securely.

Media type application/json
object
id
required

Unique API key identifier

string format: uuid
name
required

Display name for the API key

string
description

Description of the API key purpose

string
keyPrefix
required

Prefix of the API key for identification (first 8 characters)

string
permissions
required

List of permission keys granted to this API key

Array<string>
lastUsedAt

When the API key was last used

string format: date-time
expiresAt

When the API key expires

string format: date-time
createdAt
required

When the API key was created

string format: date-time
createdBy

User ID who created this API key

string format: uuid
key
required

Full API key value. Only returned on creation - store securely as it cannot be retrieved again.

string
Example
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Production CI/CD Key",
"description": "Used by GitHub Actions for automated deployments",
"keyPrefix": "mwfm_abc",
"permissions": [
"devices:read",
"deployments:read",
"deployments:write"
],
"lastUsedAt": "2024-06-20T14:45:00Z",
"expiresAt": "2025-12-31T23:59:59Z",
"createdAt": "2024-01-15T10:30:00Z",
"createdBy": "550e8400-e29b-41d4-a716-446655440001",
"key": "mwfm_abc123def456ghi789jkl012mno345pqr"
}

Invalid input data

Unauthorized

Forbidden - Insufficient permissions

Forbidden — caller lacks required permission