Test an API key with GET /api/v1/me
To test an API key, call GET /api/v1/me: a valid key gets back your business name and the key’s own name and scopes, and an invalid one gets a 401. It needs no scope, so it is the first request to send after you create a key.
What does the key test return?
Section titled “What does the key test return?”It returns the name of the business the key belongs to, the name you gave the key when you created it, and the key’s scopes:
| Field | Type | Meaning |
|---|---|---|
workspace.name | string | Your business name in Mujib |
key.name | string | The name you gave the key when you created it |
key.scopes | array of strings | The key’s scopes: contacts.read, bookings.read, or both |
This request takes no parameters.
How do I send the request?
Section titled “How do I send the request?”Send it with your key in the Authorization header:
curl https://api.mujib.ai/api/v1/me \ -H "Authorization: Bearer $MUJIB_API_KEY"const res = await fetch('https://api.mujib.ai/api/v1/me', { headers: { Authorization: `Bearer ${process.env.MUJIB_API_KEY}` },});const body = await res.json();if (!res.ok) throw new Error(`${res.status} ${body.error.code}: ${body.error.message}`);console.log(body.workspace.name, body.key.scopes);import osimport requests
res = requests.get( "https://api.mujib.ai/api/v1/me", headers={"Authorization": f"Bearer {os.environ['MUJIB_API_KEY']}"}, timeout=30,)body = res.json()if not res.ok: raise RuntimeError(f"{res.status_code} {body['error']['code']}: {body['error']['message']}")print(body["workspace"]["name"], body["key"]["scopes"])What does the response look like?
Section titled “What does the response look like?”A 200, with both fields at the top level of the body and no data wrapper:
{ "workspace": { "name": "مركز النخبة" }, "key": { "name": "تقارير المبيعات", "scopes": ["contacts.read", "bookings.read"] }}The response carries the key’s budget headers X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset, as API errors and rate limits explains.
When should I use this request?
Section titled “When should I use this request?”Use it to confirm a key works and carries the scope your system needs, before you read any data.
- When your system starts: on a 401, stop the sync and alert whoever runs the system, instead of failing every request after it.
- Before reading bookings: if
bookings.readis not inkey.scopes, skip bookings instead of collecting 403s. - After replacing a key: confirm the new key works before you revoke the old one, as API keys explains.
What errors can it return?
Section titled “What errors can it return?”| HTTP | code | Why |
|---|---|---|
| 401 | UNAUTHORIZED | No key, or a key that is invalid, revoked or expired, or a business account that is not active |
| 429 | RATE_LIMITED | You went over a rate limit |
| 500 | INTERNAL | An unexpected server error |
Frequently asked questions
Does this request need a scope?
No. Any valid key can call it, whatever its scopes.
Does it count toward the rate limit?
Yes, like any other request with a valid key. Do not send it before every request; send it when your system starts or after you change the key.
Why is there no data in this response?
Because it describes the key and its business, not a list or a record. The response carries workspace and key directly.