Skip to content

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:read permission to read and query, rag:write to 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 as TENANT. When you do not set a scope at ingestion, the document is attached to the TENANT scope and, once admitted, it can be retrieved by the authorized members of the tenant. For a private document, always send scope=USER explicitly.

ScopeVisible toNote
USERIts owner onlyMust be requested explicitly with scope=USER
PROJECTMembers of the projectRequires a project attached to the request; available depending on plan
ORGMembers of the listed organizationsReserved to platform administrators
TENANTAll members of the tenantApplied 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.

FieldTypeDefaultDescription
namestringrequiredDocument name.
typestringrequiredSource format: PDF, TXT, MARKDOWN or HTML.
collectionstringrequiredTarget collection.
filefile-File to index (multipart form), within your deployment's size limit.
contentstring-Text content, for a JSON request without a file.
scopestringTENANTUSER, PROJECT, ORG or TENANT (see Document scopes). Set USER for a private document.
orgIdsstring[]-Target organizations for the ORG scope.
metadataobject-Free-form metadata attached to the document.
chunkSizeintegerserverChunk size, minimum 100.
chunkOverlapintegerserverOverlap between chunks, minimum 0.
sourceUrlstring-Original URL of the document, for reference.
connectorIdstring-Identifier of the connector the document comes from.
skipDedupbooleanfalseDisables 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.

FieldTypeDefaultDescription
targetProjectIdstringrequiredDestination project (the x-chat-project-id header is the fallback).
idempotencyKeystringrequiredIdempotency key: replaying the same promotion does not duplicate it.
reasonstring-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.

ParameterTypeDefaultDescription
collectionstring-Filter on one collection.
statusstring-Filter on the document's indexing status.
limitinteger50Results per page.
offsetinteger0Pagination offset.
qstring-Text search on the name, 200 characters maximum.
scopestring-Filter on one scope.
nameExactstring-Exact document name, 512 characters maximum.
sincestring-Documents modified since this date (ISO 8601).
orderstring-Sort order: asc or desc.
includeExpiredboolean-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 pathPermissionDescription
GET /v1/rag/documents/{id}rag:readMetadata and bounded content. 404 NOT_FOUND if the document does not exist or is not visible.
GET /v1/rag/documents/{id}/contentrag:readFull text. maxChars parameter, bounded by a configurable ceiling.
GET /v1/rag/documents/{id}/chunksrag:readThe document's indexed chunks.
GET /v1/rag/documents/{id}/originalrag:readBinary 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.

FieldTypeDefaultDescription
querystringrequiredQuestion or text to search for.
topKinteger5Number of passages returned, from 1 to 50 (also bounded server-side).
collectionsstring[]-Restricts the search to these collections.
filtersobject-documentIds filter: list of document identifiers.
scopestring-Scope requested, checked to authorize the request (see below). Does not restrict results to one scope.
projectIdstring-Project to query, checked against your tenant. Required with scope=PROJECT.
similarityOnlyboolean-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: projectId names the project to query. It is checked against your tenant before use. With scope=PROJECT it is mandatory: the platform may answer 400 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: scope is checked to authorize the request. PROJECT requires a plan that includes that scope; TENANT and ORG are reserved to administrators. It does not turn the search into a personal search.
  • Result filters: collections and filters.documentIds bound 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:

  1. Check that projectId is set; if it is not, do not send the request.
  2. 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.
  3. Send the request with projectId and filters.documentIds, then check that every returned docId is in your selection.

Response

FieldDescription
tenantIdTenant queried.
query, topKQuery and number of passages actually applied.
passagesList of passages found.
queryTruncatedtrue if the query was truncated.
originalQueryLen, truncatedQueryLenLengths before and after truncation.

Each passage contains:

FieldDescription
docId, chunkIdIdentifiers of the document and the chunk.
collectionSource collection.
sourceSource of the document.
contentPassage text.
scoreNormalized relevance score.
scopeDocument scope.
positionPosition of the chunk in the document, when known.
relatedDocumentsRelated documents, when the knowledge graph feature is enabled on the tenant.
eligibilityNon-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

StatusCodeCauseAction
400INVALID_SCOPEscope is not a string.Send one of USER, PROJECT, ORG, TENANT.
400PROJECT_ID_REQUIREDPROJECT scope without an attached project.Attach a project to the request.
401UNAUTHORIZEDMissing, invalid, expired or revoked token.Check the token (see IAM authentication).
402SUBSCRIPTION_REQUIREDNo active subscription for the requested scope.Activate a subscription from the portal.
403FORBIDDENMissing 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.
404NOT_FOUNDDocument 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