Create API key
const url = 'http://localhost:3000/api/v1/organizations/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/api-keys';const options = { method: 'POST', headers: {'X-API-Key': '<X-API-Key>', 'Content-Type': 'application/json'}, body: '{"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"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”Organization UUID
Request Body required
Section titled “Request Body required ”object
Display name for the API key
Example
Production CI/CD KeyDescription of the API key purpose
Example
Used by GitHub Actions for automated deploymentsList of permission keys to grant to this API key
Example
[ "devices:read", "deployments:read", "deployments:write"]Expiration date for the API key in ISO 8601 format
Example
2025-12-31T23:59:59ZResponses
Section titled “ Responses ”API key created successfully. Store the key securely.
object
Unique API key identifier
Display name for the API key
Description of the API key purpose
Prefix of the API key for identification (first 8 characters)
List of permission keys granted to this API key
When the API key was last used
When the API key expires
When the API key was created
User ID who created this API key
Full API key value. Only returned on creation - store securely as it cannot be retrieved again.
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