Skip to content

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.

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:

FieldTypeMeaning
workspace.namestringYour business name in Mujib
key.namestringThe name you gave the key when you created it
key.scopesarray of stringsThe key’s scopes: contacts.read, bookings.read, or both

This request takes no parameters.

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 os
import 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"])

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.

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.read is not in key.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.
HTTPcodeWhy
401UNAUTHORIZEDNo key, or a key that is invalid, revoked or expired, or a business account that is not active
429RATE_LIMITEDYou went over a rate limit
500INTERNALAn 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.