Create API key
Creates a community API key for one community ObjectId.
- Method
- POST
- Path
https://api.returning.ai / v1/ communities/ {communityId}/ api-keys - Retries
- A timeout can hide a successful create.
Authentication#
- Header
Authorization: Bearer <API_KEY>
The managing key must belong to that community. Keep it server-side.
Behaviour#
The create body returns the raw key once in the same envelope later list/update/delete also return. Treat every management response as secret-bearing.
It does not create user API keys. Those routes are not mounted on this gateway.
Request#
Path parameters#
RuleObjectId
Headers#
Body#
RuleMin 1 chars
Eg"Slack Integration API Key"
RuleDefault []
Eg[ ... ]
RuleMin 0
Eg0
RuleDate-time
Eg"2024-12-31T23:59:59Z"
Watch for
- List/update/delete also return
key. The OpenAPI text that says list keys are masked is wrong onhttps://api.returning.ai. GET /v1/users/apikeysandGET /v1/api-key-info404.- Widget embed keys are a different credential.
More examples and details
Created (201). message is Create API key success. Envelope { meta: { status: "success", statusCode: 201 }, message, data }.
data includes _id, name, key, permissions, expirePeriod, createdAt, updatedAt.
Missing name (400). Create API key validation error. detail.name: API key name is required.
Invalid permission (400). detail.permissions lists the allowed enum. Community names include getUserData, sendMessage, leaderboard, appearance, getBulkUpdate. User-key names such as sendMessages are not valid here.
Never paste live key values into docs, tickets, or examples.
curl --request POST \
--url 'https://api.returning.ai/v1/communities/<communityId>/api-keys' \
--header 'Authorization: Bearer <API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"name": "Slack Integration API Key",
"permissions": [
"sendMessage",
"replyMessage",
"createUser",
"manageUser",
"getUserData",
"getUserStats",
"bulkUpdateUser",
"userFields"
],
"expirePeriod": 0
}'
Response#
HTTP 201. Store data.key immediately. Read back with list and match _id or name. Update keeps the same key. Delete revokes it.
Eg{"status": "success", "statusCode": 201}
Eg"success"
Eg201
Eg"Create API key success."
Eg{ ... }
Eg"675b9876fedc432109876543"
Eg"Slack Integration API Key"
Eg"<API_KEY>"
Eg[ ... ]
RuleNullable
Eg0
RuleDate-time; nullable
RuleDate-time
Eg"2024-12-15T10:30:45.123Z"
RuleDate-time
Eg"2024-12-15T10:30:45.123Z"
{
"meta": {
"status": "success",
"statusCode": 201
},
"message": "Create API key success.",
"data": {
"_id": "675b9876fedc432109876543",
"name": "Slack Integration API Key",
"key": "<API_KEY>",
"permissions": [
"sendMessage",
"replyMessage",
"createUser",
"manageUser",
"getUserData",
"getUserStats",
"bulkUpdateUser",
"userFields"
],
"expirePeriod": 0,
"expireDate": "",
"updatedAt": "2024-12-15T10:30:45.123Z",
"createdAt": "2024-12-15T10:30:45.123Z"
}
}
Errors#
Fix the request03
Fix the data02
Retry with backoff01
{
"meta": {
"status": "error",
"statusCode": 400
},
"message": "Create API key error.",
"detail": {
"name": "API key name is required"
}
}