Common API Conventions
Common rules for calling the MaiAgent platform API, including URLs and version prefixes, API Key authentication, rate limits, error responses and status codes, pagination, field formats, and upload si
This page covers the rules shared by all platform APIs: URLs, authentication, rate limits, error responses, pagination, field formats, and upload limits. See “API Endpoint Documentation” in the left sidebar for each endpoint's fields and examples. These rules apply to all endpoints and are not repeated on individual endpoint pages. Read this page before you start coding.
Base URL and Version Prefix
The SaaS API URL is https://api.maiagent.ai/api/v1/. For on-premises and private cloud deployments, replace the domain with your company's platform domain.
/api/and/api/v1/expose the same endpoints, with identical paths, fields, and permissions.AI Gateway (OpenAI-compatible endpoints) and SCIM are available only under
/api/v1/.Always use
/api/v1/for new integrations.Endpoint paths end with
/. Omitting the trailing/returns a301redirect to the URL with/appended. Some HTTP clients changePOSTtoGETwhen following redirects, so call the URL with the trailing/directly.
Authentication
For server-to-server calls, pass an API Key in the Authorization header:
Authorization: Api-Key <your API Key>A key consists of an alphanumeric prefix and secret, separated by .. Include the entire key.
Each key is bound to one member
Calls use the organization that member belongs to; requests do not need a separate organization ID
Permissions match the member's roles
There are no endpoint-specific scopes. The key can perform any action the member can. Insufficient permissions return 403; see API Key Permissions
Disabling the member invalidates the key
The key becomes unusable immediately when the member is disabled or removed from the organization
Expired, disabled, or revoked keys
Return 401, just like a nonexistent key; the response does not disclose the reason
The full key is shown only once
Only part of the key is shown after creation. Create a new key if you lose it
For where to create and manage keys, see API Authentication.
Authentication Failure Responses
A missing key, an incorrectly formatted header, or an invalid key (nonexistent, expired, disabled, revoked, or bound to a member who has been disabled or removed from the organization) all return 401 with the same content:
An invalid key also produces the message that no authentication credentials were provided. The platform treats an unrecognized key as missing credentials and does not disclose the specific reason.
The response includes a
WWW-Authenticateheader. For most endpoints, its value isBearer realm="api"(these endpoints also accept OAuth access tokens). For endpoints that accept only API Keys, such asapi-key-contextbelow, the value isApi-Key. Use the401status code to detect authentication failures; do not use this header's value to decide which credentials to send.If you put an API Key after
Bearer, the platform validates it as a login token and returns401with different content:
If you receive this response, change the header to Api-Key <key>.
Identify the Organization Associated with a Key
To check which organization a key belongs to at your own gateway, call GET /api/v1/users/api-key-context/. The response is {"organizationId": "…"}. This endpoint accepts only API Keys and does not count toward the key's RPM.
Other Credentials
To connect an MCP client as a member, see MaiAgent as an OAuth Authorization Server in the technical manual. For member tokens used to embed MaiGPT in your own system, see Integrating MaiGPT: Member Identity Embedding.
Rate Limits
The platform API has no global default limit. Only the following limits apply:
Requests per API Key (RPM)
Set by an administrator; unlimited if not set
Per key, per 60 seconds
The organization's API Key Management
AI Gateway tokens (TPM)
Set by an administrator; unlimited if not set
Per key, per minute; Gateway inference only
Same as above; see AI Gateway Limits
SCIM endpoints
100 requests/minute
Per organization
Fixed
web-chats/{id}/setup-contact-credentials/
30 requests/minute
Per source IP
Fixed
Pricing queries that require no login (credit/items/, credit/pricing-rules/)
60 requests/minute
Per source IP
Fixed
auth/login/
10 requests/minute by default
Per source IP
Platform configuration
Web Chat requests without credentials (continuing conversations, uploading attachments, etc.)
10–30 requests/minute, depending on the endpoint
Per source IP
Fixed
A key's RPM applies to all platform APIs it can call, not just AI Gateway. If an endpoint also has its own limit, such as a fixed limit in the table, API Key calls are subject to both limits. Each is counted separately; whichever is reached first returns
429, andRetry-Afteruses the longer required wait. There are two exceptions: the endpoint for identifying the organization associated with a key does not count toward the key's RPM; pricing queries that require no login (credit/items/,credit/pricing-rules/) do not recognize credentials, so even calls with an API Key are subject only to the per-source-IP limit and do not count toward the key's RPM.Requests using OAuth access tokens or back-office login sessions are not subject to key RPM limits.
Exceeding a limit returns
429with aRetry-Afterheader in seconds. Wait for that duration before retrying; do not resend immediately.
Error Responses
The platform API has no unified error code table. Handle errors based on the HTTP status code, then use code for more specific handling when present. Do not match the text in detail: it is translated according to Accept-Language, and its wording may change.
Response Shapes
detail object
{"detail": "You do not have permission to perform this action."}
Authentication, permissions, not found, rate limits, plans, and Credits; a few responses also include code or other fields
Field object
{"name": ["This field is required."]}
Field validation failures; keys are camelCase field names, and errors not tied to a single field appear in nonFieldErrors
String array
["…"]
A few validation errors without an associated field
Exceptions:
AI Gateway OpenAI-compatible endpoints use an OpenAI-format
errorobject; see AI Gateway Error Format.SCIM endpoints return request body errors, not-found errors, and conflicts according to the SCIM 2.0 specification (
schemas,status,detail).Nonexistent URLs (incorrect paths or missing resource IDs) return
404with HTML content, not JSON.5xxresponses are not guaranteed to be JSON either. CheckContent-Typebefore parsing a response.
Status Codes
200 / 201 / 204
Success; 204 has no response body and is common for deletions
—
202
Accepted but not yet complete; for example, attachments are still being indexed during a synchronous reply, returning status: "pending_attachments"
Retry later; see Cases That Do Not Enter Streaming
301
The path is missing a trailing /
Use the URL with /
400
Field validation failed; most endpoints return {"detail": "Invalid UUID format."} when a resource ID is not a valid UUID
Correct the request; do not retry
401
Credentials are missing or invalid; see Authentication Failure Responses
Check the key and header format; do not retry
403
Insufficient role permissions, the feature is not enabled for the organization, the organization is disabled, or usage has reached the limit on a character-based billing plan
Adjust role permissions or contact your representative
404
The resource does not exist, belongs to a different organization than the key, or the URL is incorrect
Check the ID, the key's organization, and the path
409
Conflicts with the resource's current state; for example, the same job is already running or a resource to be deleted is still referenced
Retrieve the latest state before deciding what to do; do not resend the same request unchanged
429
Rate limit exceeded
Back off according to Retry-After
5xx
Platform or upstream service error
Retry with exponential backoff
A 409 response is a detail object. Some endpoints include fields needed to handle the conflict, such as when an FAQ import is already running for a knowledge base:
402: Insufficient Plan Coverage, Credits, or Quota
Condition
Response Content
Includes code?
The organization has no active paid plan
{"detail": "Your organization has no active paid plan. …", "code": "no_active_plan"}
Yes, no_active_plan
The organization has insufficient Credits
{"detail": "Insufficient credits …"}; wording varies by endpoint
No
A member's personal quota is exhausted or unallocated, or their role's quota is exhausted
{"detail": "Personal credit quota exhausted. …"}; wording varies by situation
No
Only the absence of an active paid plan includes
code. Responses for insufficient Credits or exhausted quotas contain onlydetail. Currently, the response alone cannot distinguish insufficient organization Credits from an exhausted personal or role quota. Ask the organization administrator to check in the back office.Credits and quotas are checked on write requests that incur usage, such as sending messages, uploading and searching knowledge base files, and crawling web pages. Read-only
GETrequests do not return402for these reasons.AI Gateway OpenAI-compatible endpoints return the OpenAI format:
{"error": {"type": "billing_error", "code": "insufficient_credits", …}}. The samecodeis used when there is no active plan.These
402responses do not occur when Credits billing is disabled on the platform, as in some on-premises deployments.
Pagination
Most list endpoints use page-number pagination:
page
Page number, starting at 1; out-of-range values return 404 with {"detail": "Invalid page."}
page_size (also accepts pageSize)
Items per page; defaults to 20, with a maximum of 100. Values above 100 are capped at 100 without an error
The response format is {"count": …, "next": "…", "previous": "…", "results": [ … ]}. Use the next URL directly to retrieve the next page; it is null when no next page exists.
Two other cases:
Cursor pagination: The conversation list (
GET /api/v1/conversations/) and message list (GET /api/v1/messages/) use thecursorparameter to paginate from newest to oldest. Usenextto retrieve older data. The message list response includescount; the conversation list does not. Within each page of the message list, messages are ordered from oldest to newest.No pagination: Some lists return an array directly, such as
GET /api/v1/credit/items/.
Refer to each endpoint's response examples to determine which type it uses.
Field Formats
Naming: Response keys always use camelCase. Request JSON and query parameters accept both camelCase and snake_case. Some free-form field contents are preserved without case conversion, such as JSON Schema, custom HTTP headers, and metadata.
Time: Most time fields return Unix timestamps as millisecond strings, such as
"1759536000000", with second-level precision (the last three digits are always000). A few fields use ISO 8601 strings; refer to the endpoint page.Decimals: Decimal fields such as amounts and unit prices are returned as strings, such as
"316.8000000000". Use a decimal type to avoid floating-point errors.IDs: Resource IDs are usually UUIDs.
Language: Error messages are translated according to the
Accept-Languageheader (for example,ja). Messages without a translation remain in English. Do not rely on message text.
Upload Size Limits
Upload limits are configured by the platform and may change or differ for on-premises deployments. Use the response from GET /api/v1/allowed-file-specs/ as the authority. This endpoint requires no authentication and lists allowed file extensions and maxSize (in bytes) for each purpose. The production values as of October 2026 are:
Knowledge base files
100 MB
Conversation attachments: documents, spreadsheets, presentations, and audio files
10 MB
Conversation attachments: images
5 MB
Meeting recording audio files
100 MB
For presigned uploads,
POST /api/v1/upload-presigned-url/checksfileSizeand the extension when issuing the upload URL. Exceeding the limit or using a disallowed type returns400. For the workflow, see Presigned File Upload Mode in the technical manual.Excel imports for knowledge base metadata, tags, and FAQs share the knowledge base file limit.
Frequently Asked Questions
Last updated
Was this helpful?