RAG API
Reference for the Argy RAG API: collections, documents, ingestion and semantic query, with methods, paths, permissions, parameters, responses and errors.
The Argy RAG API lets you ingest documents, organize them into collections and query that corpus with semantic search from your own applications. It is aimed at integrators who feed or consult a tenant's knowledge base without going through the portal.
All routes are prefixed with https://api.argy.cloud and follow the conventions described in the API overview: Bearer authentication, JSON, error envelope. Tokens are obtained as explained in IAM authentication.
Prerequisites
- A valid token: a PAT or an Argy JWT, sent as
Authorization: Bearer $ARGY_PAT. - The
rag:readpermission to read and query,rag:writeto ingest, delete or reindex. A PAT's permissions are chosen when it is created. - RAG included in your tenant's plan (depending on your subscription).
The tenant and organizations of each call are determined server-side from your token; tenantId and orgId sent in a search request are ignored. The current project is the one exception: the projectId you provide is checked against your tenant, then used to select the project. It cannot widen what you are allowed to see.
Document scopes
Every document belongs to a scope that defines who can retrieve it.
Warning: without
scope, a document is stored asTENANT. When you do not set a scope at ingestion, the document is attached to theTENANTscope and, once admitted, it can be retrieved by the authorized members of the tenant. For a private document, always sendscope=USERexplicitly.
| Scope | Visible to | Note |
|---|---|---|
USER | Its owner only | Must be requested explicitly with scope=USER |
PROJECT | Members of the project | Requires a project attached to the request; available depending on plan |
ORG | Members of the listed organizations | Reserved to platform administrators |
TENANT | All members of the tenant | Applied when scope is omitted; reserved to administrators when requested explicitly |
A USER document can be promoted to a project (see Promote a document).
Collections
A collection is a free-form name that groups documents. There is no creation route: a collection appears as soon as a document is ingested into it.
List collections
GET /v1/rag/collections (permission rag:read).
Returns the distinct collection names of the calling tenant.
curl https://api.argy.cloud/v1/rag/collections \
-H "Authorization: Bearer $ARGY_PAT"
Document ingestion
Ingest a document
POST /v1/rag/documents (permission rag:write).
The request is either a multipart/form-data form with a file, or a JSON body carrying the text content.
| Field | Type | Default | Description |
|---|---|---|---|
name | string | required | Document name. |
type | string | required | Source format: PDF, TXT, MARKDOWN or HTML. |
collection | string | required | Target collection. |
file | file | - | File to index (multipart form), within your deployment's size limit. |
content | string | - | Text content, for a JSON request without a file. |
scope | string | TENANT | USER, PROJECT, ORG or TENANT (see Document scopes). Set USER for a private document. |
orgIds | string[] | - | Target organizations for the ORG scope. |
metadata | object | - | Free-form metadata attached to the document. |
chunkSize | integer | server | Chunk size, minimum 100. |
chunkOverlap | integer | server | Overlap between chunks, minimum 0. |
sourceUrl | string | - | Original URL of the document, for reference. |
connectorId | string | - | Identifier of the connector the document comes from. |
skipDedup | boolean | false | Disables duplicate detection at ingestion. |
Response: 201 with the metadata of the created document.
curl -X POST https://api.argy.cloud/v1/rag/documents \
-H "Authorization: Bearer $ARGY_PAT" \
-F "name=onboarding-guide" \
-F "type=MARKDOWN" \
-F "collection=internal-docs" \
-F "scope=USER" \
-F "file=@onboarding-guide.md"
Depending on the deployment, a document may go through an admission step before it is indexed; its status is then visible in the document list.
Reindex a document
POST /v1/rag/documents/{id}/reindex (permission rag:write). Response 202: reindexing is asynchronous.
Delete a document
DELETE /v1/rag/documents/{id} (permission rag:write). Response 200. The deletion is recorded in the audit log with the actor.
The optional x-chat-project-id header ties the deletion to a project: it is checked against the tenant before it is taken into account.
Promote a document
POST /v1/rag/documents/{id}/promotions (permission rag:write).
Moves a document from the USER scope to a project.
| Field | Type | Default | Description |
|---|---|---|---|
targetProjectId | string | required | Destination project (the x-chat-project-id header is the fallback). |
idempotencyKey | string | required | Idempotency key: replaying the same promotion does not duplicate it. |
reason | string | - | Reason, 500 characters maximum. |
Response: 200. Without a target project, the request fails with 400 PROJECT_ID_REQUIRED.
Read documents
List documents
GET /v1/rag/documents (permission rag:read). Response 200: paginated list.
| Parameter | Type | Default | Description |
|---|---|---|---|
collection | string | - | Filter on one collection. |
status | string | - | Filter on the document's indexing status. |
limit | integer | 50 | Results per page. |
offset | integer | 0 | Pagination offset. |
q | string | - | Text search on the name, 200 characters maximum. |
scope | string | - | Filter on one scope. |
nameExact | string | - | Exact document name, 512 characters maximum. |
since | string | - | Documents modified since this date (ISO 8601). |
order | string | - | Sort order: asc or desc. |
includeExpired | boolean | - | Includes expired documents. |
The orgId filter and any project identifier sent by the client are stripped from the request: the list is always bounded to your own scope.
Read one document
| Method and path | Permission | Description |
|---|---|---|
GET /v1/rag/documents/{id} | rag:read | Metadata and bounded content. 404 NOT_FOUND if the document does not exist or is not visible. |
GET /v1/rag/documents/{id}/content | rag:read | Full text. maxChars parameter, bounded by a configurable ceiling. |
GET /v1/rag/documents/{id}/chunks | rag:read | The document's indexed chunks. |
GET /v1/rag/documents/{id}/original | rag:read | Binary stream of the original file, served directly by the API (no storage URL is exposed). |
Downloading the original can fail with 504 GATEWAY_TIMEOUT or 502 BAD_GATEWAY when storage is unavailable.
Semantic query
POST /v1/rag/query (permission rag:read).
Finds the passages closest to your question among the documents you are allowed to see. The search aggregates the authorized documents of several scopes (tenant documents, those of your organizations, your project and your personal documents): it does not return only your personal documents.
| Field | Type | Default | Description |
|---|---|---|---|
query | string | required | Question or text to search for. |
topK | integer | 5 | Number of passages returned, from 1 to 50 (also bounded server-side). |
collections | string[] | - | Restricts the search to these collections. |
filters | object | - | documentIds filter: list of document identifiers. |
scope | string | - | Scope requested, checked to authorize the request (see below). Does not restrict results to one scope. |
projectId | string | - | Project to query, checked against your tenant. Required with scope=PROJECT. |
similarityOnly | boolean | - | Deduplication mode: returns only passages above a similarity threshold set by the server. |
curl -X POST https://api.argy.cloud/v1/rag/query \
-H "Authorization: Bearer $ARGY_PAT" \
-H "Content-Type: application/json" \
-d '{
"query": "How does the onboarding procedure work?",
"topK": 5,
"collections": ["internal-docs"]
}'
Project, authorization and filters
Three separate mechanisms apply to a search:
- Project selection:
projectIdnames the project to query. It is checked against your tenant before use. Withscope=PROJECTit is mandatory: the platform may answer400 PROJECT_ID_REQUIRED, but that refusal is not guaranteed in every case (some requests without a project are handled as personal searches, and administrators skip this check). Do not rely on it: check yourself that the project is supplied. - Request authorization:
scopeis checked to authorize the request.PROJECTrequires a plan that includes that scope;TENANTandORGare reserved to administrators. It does not turn the search into a personal search. - Result filters:
collectionsandfilters.documentIdsbound the corpus that is queried. Use them to target the documents you want.
To target a specific corpus, combine collections or filters.documentIds with the projectId you want, rather than relying on scope.
An empty filters.documentIds list (or one containing only blank identifiers) is treated as no filter at all: the search then covers every document you can see, not none. On the integration side, apply this recipe before each targeted search:
- Check that
projectIdis set; if it is not, do not send the request. - Check that your document selection is not empty; if it is, do not run the search and treat the case as "no document selected" in your application.
- Send the request with
projectIdandfilters.documentIds, then check that every returneddocIdis in your selection.
Response
| Field | Description |
|---|---|
tenantId | Tenant queried. |
query, topK | Query and number of passages actually applied. |
passages | List of passages found. |
queryTruncated | true if the query was truncated. |
originalQueryLen, truncatedQueryLen | Lengths before and after truncation. |
Each passage contains:
| Field | Description |
|---|---|
docId, chunkId | Identifiers of the document and the chunk. |
collection | Source collection. |
source | Source of the document. |
content | Passage text. |
score | Normalized relevance score. |
scope | Document scope. |
position | Position of the chunk in the document, when known. |
relatedDocuments | Related documents, when the knowledge graph feature is enabled on the tenant. |
eligibility | Non-sensitive justification of why the passage is visible: { scope, reason }. |
The eligibility field explains why a passage is visible to you; it does not influence ranking.
Common errors
| Status | Code | Cause | Action |
|---|---|---|---|
| 400 | INVALID_SCOPE | scope is not a string. | Send one of USER, PROJECT, ORG, TENANT. |
| 400 | PROJECT_ID_REQUIRED | PROJECT scope without an attached project. | Attach a project to the request. |
| 401 | UNAUTHORIZED | Missing, invalid, expired or revoked token. | Check the token (see IAM authentication). |
| 402 | SUBSCRIPTION_REQUIRED | No active subscription for the requested scope. | Activate a subscription from the portal. |
| 403 | FORBIDDEN | Missing permission, PROJECT scope not included in the tenant's plan, or TENANT/ORG scope without an administrator role. | Create a token carrying rag:read or rag:write, or move to a plan that includes the PROJECT scope. |
| 404 | NOT_FOUND | Document missing or not visible. | Check the identifier and the scope. |
| 413 | - | File above the size limit. | Split or compress the file. |
The number of RAG queries per month is subject to a quota, checked before each search. Quotas can be viewed from the portal: see Portal billing.
See also
- API overview: conventions, headers, error envelope and limits
- IAM authentication: obtain a token and choose its permissions
- LLM Gateway: generate an answer from the retrieved passages
- Argy Chat: the assistant that relies on your projects' RAG documents
- Argy AI in the portal: manage RAG documents from the interface
- Security model