Get started
Authentication with API keys
Every request to the myid API carries a secret API key in the Authorization header and must come from an IP that the key allows. Keys belong to your company and are managed in the panel.
API keys
Create keys in the panel under Developers → API keys. Only the company owner or an admin can create, rotate or revoke keys.
- A key looks like
myid_sk_followed by a 12-character prefix and a secret part. - The full key is shown once, when you create or rotate it. After that the panel shows only a masked form.
- You can set an expiry date. An expired key stops working on that date.
- A company can have up to 20 active keys, for example one per environment or service.
Sending the key
Send the key as a Bearer token in every request:
curl https://api.myid.ir/v1/flows \
-H "Authorization: Bearer $MYID_API_KEY"Allowed IPs
Every key has a list of server IPs that may use it. You enter it when you create the key, and it can't be empty.
- Add up to 20 entries, one per line: an IPv4 or IPv6 address, or a CIDR range such as
198.51.100.0/24. - Ranges can be at most
/8wide for IPv4 and/32for IPv6, so0.0.0.0/0is not accepted. - Change the list at any time with Edit on the key in the panel. A rotated key keeps the same list.
- Keys made before allowed IPs were required have an empty list and are refused until you add your server IPs.
A valid key sent from another IP gets HTTP 403 with status: "forbidden". The message names the IP the API saw, so you can add it:
{
"response": {
"status": "forbidden",
"message": "Requests from 203.0.113.50 are not allowed for this API key. Add this IP to the key's allowed IPs in the panel."
}
}Rotating a key
Rotate a key in the panel to get a new secret. You can keep the old one working for a grace period of 0 to 168 hours, so you can deploy the new key without downtime.
Revoking a key
Revoke a key when it is no longer used or may have leaked. It stops working immediately and cannot be turned back on.
When authentication fails
A missing, wrong, expired or revoked key gets HTTP 401 with status: "need-auth":
{
"response": {
"status": "need-auth",
"message": "The API key is invalid, expired or revoked."
}
}