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
- Provide a roleId for scoped permissions (e.g., read-only)
Expiration options:
- Use expiresInDays for fixed expiration (7, 30, 90, 180, 365)
- Set expiresInDays to null for never-expiring keys
Body
required
application/json
- Type: stringnamerequired
Display name for the API key
- Type: integer nullableexpires
In Days Days until expiration (null = never expires)
- Type: objectmetadata
Additional metadata to store with the key
- Type: stringFormat: uuid nullablerole
Id Role to assign (null = inherit user's roles)
Responses
- application/json
- application/json
- application/json
- 403
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"
}
}.png)