UC-020 — API Key Management
- Goal
- Create, inspect and revoke API Keys for your account
- Channel
- All
- Estimated time
- 5 minutes
Real-world scenarios
- Developer onboarding: The team lead creates a dedicated API Key for a new integration, scoped to only the operations that integration needs.
- Periodic key rotation: FinSecure rotates its API Keys every 90 days as required by internal security policy.
- Revoke a compromised key: A developer accidentally committed an API Key to a public repository and needs to revoke it at once, knowing that the messaging endpoints can keep accepting it for up to 24 hours (see Step 4).
Management flow
The diagram shows the complete API Key lifecycle: scope check, creation, listing and revocation.
Prerequisites
- Active account on the Qlara platform
- At least one existing API Key to authenticate management calls
- The calling key must be authorized for the
AUTHENTICATIONoperation
Step 1 — Check what your current key can do
Before creating a key, inspect the one you are calling with. A new key can only be granted operations the calling key already holds, so this tells you the maximum scope available to you.
curl -X GET https://api.qlara.ai/api/partner-gateway/authentication/me \
-H "X-Api-Key: YOUR_API_KEY"
Response — Current key
{
"id": 1,
"companyId": 100,
"userId": 42,
"username": "api-user",
"trafficType": 0,
"operations": ["AUTHENTICATION", "SMS", "RCS", "WHATSAPP"],
"creationDate": "2025-03-10 14:30:00.000+0100",
"lastUpdateDate": "2025-03-10 14:30:00.000+0100"
}
The key is read from the X-Api-Key header, so this endpoint takes no parameters and never
echoes the key value back. It replaces the removed GET /authentication/{value}, which took a
raw key in the URL.
Step 2 — Create a new API Key
Call the creation endpoint to generate a new key.
curl -X POST https://api.qlara.ai/api/partner-gateway/authentication \
-H "Content-Type: application/json" \
-H "X-Api-Key: YOUR_API_KEY" \
-d '{
"userId": 4618,
"trafficType": 0,
"operations": ["SMS", "RCS", "WHATSAPP"]
}'
| Field | Required | Description |
|---|---|---|
userId | Yes | ID of the user the key belongs to, normally the integration owner. It must be a member of your team who has accepted the invitation, the calling key's own userId included: a user of another company, a pending invitation or a suspended member gets 400. |
operations | Yes | Operations the key may call on the Qlara Platform endpoints (/api/partner-gateway): each one opens the endpoints under the path of the same name. Must be a non-empty subset of the operations held by the calling key. |
trafficType | No | Traffic type identifier (0 = standard, the default). A key can grant only 0 or its own traffic type: any other value gets 403. Leave at 0 unless instructed otherwise. |
Allowed values for operations, with the Qlara Platform endpoints each one opens:
| Operation | Opens | What is there |
|---|---|---|
AUTHENTICATION | /authentication | API Keys: this use case |
CAMPAIGNS | /campaigns | Campaigns: create, update, price, confirm, statistics |
CONTACTS | /contacts | Contacts, contact lists and imports |
EXPORTS | /exports | Exports of delivery reports and contacts |
INBOX | /inbox | Conversations: read, reply, assign, archive |
MEDIA | /media | Media gallery: upload, list, delete |
MESSAGES | /messages | Delivery status, message history and its export |
RCS | /rcs | RCS agents and status of RCS messages |
SMS | /sms | SMS senders |
SOCIALS | /socials | Connected social profiles |
SUBSCRIPTION | /subscription | Subscription and credit |
WEBHOOKS | /webhooks | Delivery-status webhook |
WHATSAPP | /whatsapp | WhatsApp Business numbers and status of WhatsApp messages |
AUTOMATION, CALENDAR, EMAIL, REPORT | — | No endpoint |
Operations scope only the Qlara Platform endpoints (/api/partner-gateway), where a call outside the key's operations gets 401. The messaging endpoints (/api/message-server) and media downloads (/api/files) accept any key of your account, whatever its operations: every key you hand out can send SMS, RCS, WhatsApp and email messages and spend credit. A key is therefore no isolation boundary for sending. See Operations and revocation.
Response — Key created
{
"id": 3,
"companyId": 100,
"userId": 4618,
"apiKey": "Ab3dK7pQ2vLx9mRt4sNw8yZc1bHf6jDg0eUa5iOWx9z",
"username": null,
"trafficType": 0,
"operations": ["SMS", "RCS", "WHATSAPP"],
"creationDate": "2026-02-02 10:15:00.000+0100",
"lastUpdateDate": "2026-02-02 10:15:00.000+0100"
}
The apiKey field is shown only at creation time. Copy it and store it in a secret manager
(e.g. Vault, AWS Secrets Manager). It cannot be retrieved again through any endpoint.
Keys created here are identified by their id and userId and carry no username, so username
in the response is always null. A username sent in the request body is ignored.
Behind the scenes — Key generation and scoping
- Authorization: The gateway resolves the calling key and checks it is authorized for the
AUTHENTICATIONoperation. - Scope check: The requested
operationsare compared against the calling key's own operations. Anything beyond them is refused with403— a key cannot grant privileges it does not have. The same holds for atrafficTypeother than0or the calling key's own. - User check: The
userIdmust be an accepted member of your team; otherwise the request is refused with400. - Generation: A 43-character key string is generated and returned once, in this response only.
- Association: The key is linked to the company of the calling key and to the
userIdyou supplied.
Step 3 — List existing keys
Retrieve the API Keys associated with your account. Add the optional userId query parameter to
filter by owner.
curl -X GET https://api.qlara.ai/api/partner-gateway/authentication \
-H "X-Api-Key: YOUR_API_KEY"
Response — Key list
[
{
"id": 1,
"companyId": 100,
"userId": 42,
"apiKey": "Kf8t***********************************Qe4n",
"username": "api-user",
"trafficType": 0,
"operations": ["AUTHENTICATION", "SMS", "RCS", "WHATSAPP"],
"creationDate": "2025-03-10 14:30:00.000+0100",
"lastUpdateDate": "2025-03-10 14:30:00.000+0100"
},
{
"id": 2,
"companyId": 100,
"userId": 5172,
"apiKey": "Zq7m***********************************Lp2k",
"username": null,
"trafficType": 0,
"operations": ["SMS", "WHATSAPP"],
"creationDate": "2026-01-15 09:00:00.000+0100",
"lastUpdateDate": "2026-01-15 09:00:00.000+0100"
},
{
"id": 3,
"companyId": 100,
"userId": 4618,
"apiKey": "Ab3d***********************************Wx9z",
"username": null,
"trafficType": 0,
"operations": ["SMS", "RCS", "WHATSAPP"],
"creationDate": "2026-02-02 10:15:00.000+0100",
"lastUpdateDate": "2026-02-02 10:15:00.000+0100"
}
]
The response is a plain array of all your keys, with no pagination: here the calling key (1), an older key (2) and the key created in Step 2 (3). Each key appears masked in apiKey, with only its first and last 4 characters visible, so you can tell your keys apart: the full value is never returned by this endpoint. userId is null on some older keys.
Step 4 — Revoke a compromised key
Delete a key that should no longer be used. The key id goes in the path: here key 2.
curl -X DELETE https://api.qlara.ai/api/partner-gateway/authentication/2 \
-H "X-Api-Key: YOUR_API_KEY"
Response — Key revoked
204 No Content — the response has no body. A key that does not exist, or belongs to another account, returns 404. A key that holds an operation the calling key does not hold returns 403.
Behind the scenes — What happens after revocation
- Immediate invalidation on the Qlara Platform: The key is removed from the Key Store, and from then on requests to the Qlara Platform endpoints (
/api/partner-gateway) that use it receive401 Unauthorized. The messaging endpoints (/api/message-server) and/api/fileskeep a cached copy of the keys they have checked, so they can keep accepting the deleted key, and sending messages with it, for up to 24 hours. To cut off a leaked key, revoke it, treat it as still live on those endpoints for up to a day, and contact Qlara support. - No rollback: Deletion is irreversible. To restore access, create a new key.
- Which keys you can delete: A key can delete itself and any key of your account whose operations are all among its own, with or without a
userId: here key1holds both operations of key2. When the key to delete holds an operation that the calling key does not hold, the answer is403and nothing is deleted.
Expected result
| Step | Action | Result |
|---|---|---|
| 1 | GET /authentication/me | 200 OK with the calling key's operations |
| 2 | POST /authentication | 201 Created, full apiKey returned once |
| 3 | GET /authentication | 200 OK with the array of keys (masked key values, first and last 4 characters visible) |
| 4 | DELETE /authentication/{id} | 204 No Content |
Complete end-to-end example
Scenario FinSecure: quarterly key rotation.
BASE=https://api.qlara.ai/api/partner-gateway
# 1. Read the calling key: its id (the key to retire) and the scope it can grant
ME=$(curl -s -X GET "$BASE/authentication/me" -H "X-Api-Key: $CURRENT_KEY")
OLD_KEY_ID=$(echo "$ME" | jq -r '.id')
echo "$ME" | jq '.operations'
# 2. Create the new key, scoped to the same operations: AUTHENTICATION lets it revoke the old one
NEW_KEY=$(curl -s -X POST "$BASE/authentication" \
-H "Content-Type: application/json" \
-H "X-Api-Key: $CURRENT_KEY" \
-d '{
"userId": 4618,
"trafficType": 0,
"operations": ["AUTHENTICATION", "SMS", "RCS", "WHATSAPP"]
}' | jq -r '.apiKey')
echo "New key: $NEW_KEY"
# 3. Verify the new key works and inspect its scope
curl -s -X GET "$BASE/authentication/me" \
-H "X-Api-Key: $NEW_KEY" | jq '{id, operations}'
# 4. Revoke the old key by its id
curl -s -o /dev/null -w "%{http_code}\n" \
-X DELETE "$BASE/authentication/$OLD_KEY_ID" \
-H "X-Api-Key: $NEW_KEY"
Variants
Create a least-privilege key per integration
Scope each key to the smallest set of operations that covers its job on the Qlara Platform endpoints. This limits what the key can read and change there, not what it can send: any key of your account can send through the messaging endpoints and spend credit, whatever its operations.
# Key that can only list the SMS senders (GET /sms/senders)
curl -X POST https://api.qlara.ai/api/partner-gateway/authentication \
-H "Content-Type: application/json" \
-H "X-Api-Key: YOUR_API_KEY" \
-d '{"userId": 4618, "operations": ["SMS"]}'
# Marketing automation key
curl -X POST https://api.qlara.ai/api/partner-gateway/authentication \
-H "Content-Type: application/json" \
-H "X-Api-Key: YOUR_API_KEY" \
-d '{"userId": 4618, "operations": ["CONTACTS", "CAMPAIGNS", "MESSAGES"]}'
Common errors
400 Bad Request — Missing or empty operations
{
"status": "fail",
"data": [
["operations is required: a key with no operations cannot call any /api/partner-gateway endpoint"]
]
}
Solution: Send a non-empty operations array. A key with no operations cannot call any Qlara Platform endpoint. A missing userId is reported the same way, with the message userId is required.
400 Bad Request — userId not in your team
{
"status": "fail",
"data": "userId is not a user of your company"
}
Solution: Use the id of a member of your team who has accepted the invitation. A user of another company, a pending invitation or a suspended member is refused, and so is the calling key's own userId if it is not such a member.
401 Unauthorized — Invalid key
{
"error": "Invalid API Key"
}
Solution: Verify that the X-Api-Key header is present and that the key used to manage other keys is still active and authorized for the AUTHENTICATION operation.
403 Forbidden — Requested operations exceed your scope
{
"status": "fail",
"data": "Cannot grant operations beyond the caller's own scope: [CAMPAIGNS]"
}
Solution: A key cannot grant privileges it does not have: data lists the operations refused. Call GET /authentication/me to see what the calling key holds, then request a subset of those operations. A trafficType other than 0 or the calling key's own is refused the same way, with Cannot grant a traffic type other than 0 or the caller's own: followed by the value.
404 Not Found — Key does not exist
Solution: No key with that id exists in your account: it does not exist, or it belongs to another company. Check the id in the path against the list returned by GET /authentication.
Next steps
- UC-022 — Monitor Credit and Subscription: Check the status of your subscription and remaining credit
- UC-001 — Bulk SMS Campaign: Use your new key to send your first campaign
- Authentication Guide: Full details on API Key and Basic Auth