Skip to content
Contextely

Reference

Partner API

For embedding Contextely in a product you sell. Your backend provisions a workspace per client and a key per person; retrieval then happens on the ordinary API with that key. What the arrangement covers.

Two credentials, and why

An organization key (ctx_org_...) provisions. It creates client workspaces, the people inside them and their keys, and it reads pooled usage. It can never read a client's memory.

A workspace key (ctx_sk_...) retrieves. It resolves to exactly one person, and every answer it gets is scored against that person's entitlement scopes. That is what makes it safe to hand to an agent: an agent holding Priya's key sees exactly what Priya sees.

Keep the organization key on your server.

The partner endpoints send no CORS headers and are not usable from a browser by design. One of these reaching client-side code would expose every client you have, not one person's view.

Create one in the partner console, under Clients then Organization keys. That screen exists because you cannot mint the first organization key with an organization key. There is no CLI for provisioning: partners integrate server to server, and a second surface is a second thing to keep in step.

Provisioning a client

The first three calls are idempotent, on external_refand on email respectively, so you can run them on every one of your customer's logins rather than tracking which ones you have already created. The response says created either way.

Create a client

# 1. A new client signs up in your product. Idempotent on external_ref,
#    so you can call this on every one of their logins.
curl -s https://www.contextely.com/api/v1/org/tenants \
  -H "Authorization: Bearer ctx_org_..." \
  -H "Content-Type: application/json" \
  -d '{"external_ref":"cust_8812","name":"Acme Ltd","query_cap":25000}'

Create a person and mint their key

# 2. One person inside that client. `scopes` is whatever your own
#    permission model says they may see.
curl -s https://www.contextely.com/api/v1/org/tenants/$TENANT/members \
  -H "Authorization: Bearer ctx_org_..." \
  -H "Content-Type: application/json" \
  -d '{"email":"priya@acme.example","role":"member","scopes":["finance:*"]}'

# 3. A key that speaks as exactly that person. Shown once. You store it.
curl -s https://www.contextely.com/api/v1/org/tenants/$TENANT/keys \
  -H "Authorization: Bearer ctx_org_..." \
  -H "Content-Type: application/json" \
  -d '{"member_id":"'$MEMBER'"}'

Retrieve on their behalf

# 4. From here it is the ordinary product. This answer is scored
#    against Priya's entitlement, not against your key's.
curl -s https://www.contextely.com/api/v1/search \
  -H "Authorization: Bearer ctx_sk_..." \
  -H "Content-Type: application/json" \
  -d '{"query":"acme renewal date"}'

Pooled usage

curl -s https://www.contextely.com/api/v1/org/usage \
  -H "Authorization: Bearer ctx_org_..."

No email is ever sent to a person you provision. They have no Contextely account, they are never invited to make one, and their row cannot be claimed by anyone who later signs up with the same address.

Caps, the pool, and what refuses

Each client has a cap you set. The organization has a pooled allowance of 250,000 retrievals and 40,000 refreshes a month. The two behave differently on purpose.

ConditionWhat happensYour move
A client reaches its cap402 quota_exceeded, in a message that names no plan and no brandRaise the cap. It applies to their next request
The pool passes its included volumeNothing. It bills as overage and keeps servingNothing, unless you want to spend less
The organization ceiling is reached402 for every clientGet in touch. This is runaway protection, not a plan limit
The subscription lapsesProvisioning returns 403; retrieval keeps working while the card is retriedUpdate the card in the billing portal

A hard stop at the included volume would turn a billing event into a simultaneous outage across every client you have, so the pool does not have one. Only a client's own cap and the runaway ceiling refuse.

Raise one client's cap

curl -s https://www.contextely.com/api/v1/org/tenants/$TENANT \
  -H "Authorization: Bearer ctx_org_..." \
  -H "Content-Type: application/json" \
  -d '{"query_cap":50000}'

Every endpoint

All under /api/v1, all taking an organization key. Asking for a client that belongs to a different organization answers not_found, the same as asking for one that does not exist: a distinguishable refusal would tell you which of your competitors is also a customer.

GET/orgThe organization this key belongs to
POST/org/tenantsCreate a client workspace, or return the existing one
GET/org/tenantsList client workspaces
GET/org/tenants/{tenant_id}One client workspace
POST/org/tenants/{tenant_id}Update a client workspace
DELETE/org/tenants/{tenant_id}Remove a client workspace and everything in it
POST/org/tenants/{tenant_id}/membersCreate a person inside a client
GET/org/tenants/{tenant_id}/membersList the people inside a client
POST/org/tenants/{tenant_id}/members/{member_id}Change a person's role or scopes
DELETE/org/tenants/{tenant_id}/members/{member_id}Remove a person from a client
POST/org/tenants/{tenant_id}/keysMint a retrieval key for one person
GET/org/tenants/{tenant_id}/keysList a client's keys
DELETE/org/tenants/{tenant_id}/keys/{key_id}Revoke a key
POST/org/tenants/{tenant_id}/sourcesConnect a client's system of record
GET/org/tenants/{tenant_id}/sourcesList a client's connected sources
POST/org/tenants/{tenant_id}/ingestSync one of a client's sources
GET/org/tenants/{tenant_id}/auditA client's retrieval log
GET/org/usagePooled usage, and the per-tenant breakdown

Generated from the same catalogue as the OpenAPI document, so neither can describe an endpoint that does not exist.

What you cannot do

There is no endpoint that returns a client's memory objects to an organization key, and no way to act as one of their people from the console. Your staff are not members of your clients' workspaces.

When you need to debug, mint a key for a person inside that client and use it. That leaves an entry in their own retrieval log, which you can read with GET /org/tenants/{id}/audit. It is the accountable path rather than the convenient one, and it is worth telling your own customers about.