Organizations and workspaces
Invite people to your organization, manage roles and memberships, review organization memory suggestions, and split spend across workspaces.
An organization is the tenant your key belongs to: it owns the members, vaults, shared memory, rules, and workspaces that a key can reach. Every call on this page acts on the organization your key names. There is no organization id to pass, and no way to address another organization.
Roles
A member has one of three roles: owner, admin, or member.
- Owners and admins manage the organization: they list and invite
members, change roles, remove members, manage workspaces, and review memory
suggestions. A
memberwho calls one of those routes gets403org_forbidden, orworkspace_forbiddenon a workspace route. - An owner's membership is immutable. Nobody can change an owner's role or
remove an owner, and an owner cannot leave, so an organization always keeps
one. Granting
ownerrequires the caller to be an owner.
A role does not open a vault: an admin reads a vault's content only as a member of it.
Invite someone
POST /api/v1/org/members invites a person, addressed by email or by
user_id, exactly one of the two. role is member (the default) or
admin; to make someone an owner, change their role after they join.
curl https://api.cruxy.ai/api/v1/org/members \
-H "Authorization: Bearer $CRUXY_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "email": "[email protected]", "role": "member" }'const res = await fetch('https://api.cruxy.ai/api/v1/org/members', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CRUXY_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ email: '[email protected]', role: 'member' }),
})
if (!res.ok) throw new Error(`invite failed: ${res.status} ${await res.text()}`)
const invitation = await res.json()
console.log(invitation.id, invitation.status, invitation.expires_at)The call creates an invitation, not a membership: nobody joins an
organization without accepting. It answers 202 with the invitation, and the
answer is the same whether or not the address has an account, so the call
cannot be used to find out who does. Re-inviting an address with a live
invitation returns that invitation unchanged, and one whose invitation has
lapsed gets a fresh 14-day window. Inviting someone who is already a member is
409 org_member_exists.
GET /api/v1/org/invitations lists the invitations your organization has
sent, live and settled, each with its email, role, and a status of
pending, accepted, declined, or revoked.
DELETE /api/v1/org/invitations/{invitation_id} withdraws one before it is
accepted.
Accept or decline an invitation
The person invited acts with their own key. GET /api/v1/invitations lists
the live invitations addressed to them across every organization, each with
the inviting organization's org_name and the inviter's invited_by_email.
# See what you have been invited to.
curl https://api.cruxy.ai/api/v1/invitations \
-H "Authorization: Bearer $CRUXY_API_KEY"
# Accept one, by its id. To decline instead, POST to .../decline.
curl -X POST https://api.cruxy.ai/api/v1/invitations/$INVITATION_ID/accept \
-H "Authorization: Bearer $CRUXY_API_KEY"const headers = { Authorization: `Bearer ${process.env.CRUXY_API_KEY}` }
const inbox = await fetch('https://api.cruxy.ai/api/v1/invitations', { headers })
if (!inbox.ok) throw new Error(`inbox failed: ${inbox.status}`)
const { data } = await inbox.json()
for (const invitation of data) {
console.log(`${invitation.org_name} invites you as ${invitation.role}`)
console.log(` from ${invitation.invited_by_email}, until ${invitation.expires_at}`)
}
const first = data[0]
if (first) {
const res = await fetch(`https://api.cruxy.ai/api/v1/invitations/${first.id}/accept`, {
method: 'POST',
headers,
})
if (!res.ok) throw new Error(`accept failed: ${res.status} ${await res.text()}`)
const membership = await res.json()
console.log(`joined ${membership.org_name} as ${membership.role}`)
}POST /api/v1/invitations/{invitation_id}/acceptjoins the organization with the role the invitation offered and returns the new membership.POST /api/v1/invitations/{invitation_id}/declinesettles the invitation and creates nothing. It answers204. The inviting organization sees the outcome on its invitation list.
An invitation that names somebody else, one that expired, one already settled,
and one that never existed are all 404 invitation_not_found.
Once you belong to more than one organization, issuing a new key can no
longer pick an organization for you: the request must name one, or it is
refused with org_selection_required. Existing keys are unaffected.
Memberships
GET /api/v1/org/memberships lists the organizations you belong to, with
your role in each. DELETE /api/v1/org/memberships/{org_id} removes your
own membership from the organization the path names. Any member may leave; an
owner cannot, and gets 403 org_forbidden. It is the one call on this page
that takes an organization id, because the organization you leave need not be
the one your key names.
Change a role or remove a member
GET /api/v1/org/members lists the organization's members with each one's
user_id, email, and role.
PATCH /api/v1/org/members/{user_id}with{"role": "admin"}changes a member's role.DELETE /api/v1/org/members/{user_id}removes a member.
Removing a member, or leaving, ends access and destroys nothing. The person's API keys bound to the organization are revoked in the same step. The memory they wrote at organization and vault scope is kept and frozen until an owner or admin settles it, and their own personal memory is never touched.
POST /api/v1/memories/departed/{user_id} settles a departed member's shared
memory with a disposition: keep retains every row and moves authorship to
you, and purge deletes them. The response reports how many rows were
affected. A user who is still a member is 409 org_member_active, and
one who wrote nothing in your organization is 404 org_member_not_found.
Suggest organization memory
Only an owner or admin can turn a suggestion into organization memory, and any
member can make one.
POST /api/v1/memories/suggestions takes a key and a value. A suggestion
is not memory: it is never recalled or added to a turn until it is approved.
# Any member: propose a memory for the whole organization.
curl https://api.cruxy.ai/api/v1/memories/suggestions \
-H "Authorization: Bearer $CRUXY_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "key": "deploy-window", "value": "Production deploys go out on Tuesdays." }'
# An owner or admin: read the pending queue, then approve one by its id.
curl "https://api.cruxy.ai/api/v1/memories/suggestions?status=pending" \
-H "Authorization: Bearer $CRUXY_API_KEY"
curl -X POST https://api.cruxy.ai/api/v1/memories/suggestions/$SUGGESTION_ID/approve \
-H "Authorization: Bearer $CRUXY_API_KEY"const base = 'https://api.cruxy.ai/api/v1/memories/suggestions'
const headers = {
Authorization: `Bearer ${process.env.CRUXY_API_KEY}`,
'Content-Type': 'application/json',
}
// Any member: propose a memory for the whole organization.
const suggested = await fetch(base, {
method: 'POST',
headers,
body: JSON.stringify({
key: 'deploy-window',
value: 'Production deploys go out on Tuesdays.',
}),
})
if (!suggested.ok) throw new Error(`suggest failed: ${suggested.status} ${await suggested.text()}`)
// An owner or admin: read the pending queue and approve each entry.
const queue = await fetch(`${base}?status=pending`, { headers })
if (!queue.ok) throw new Error(`queue failed: ${queue.status}`)
const { data } = await queue.json()
for (const suggestion of data) {
const res = await fetch(`${base}/${suggestion.id}/approve`, { method: 'POST', headers })
if (!res.ok) throw new Error(`approve failed: ${res.status} ${await res.text()}`)
const approved = await res.json()
console.log(approved.key, approved.status, approved.memory_id)
}- Suggesting. Suggesting a key you already have pending replaces that
pending value. The checks on a memory write apply: an empty value is
refused, and content carrying obvious personal data is
400pii_rejected. - Listing.
GET /api/v1/memories/suggestionsreturns the newest 200. An owner or admin sees every member's; any other member sees only their own.statusnarrows it topending,approved, orrejected. - Approving.
POST /api/v1/memories/suggestions/{id}/approvewrites the suggestion as organization memory under its key, replacing any organization memory already stored for that key, and names what it wrote inmemory_id. - Rejecting.
POST /api/v1/memories/suggestions/{id}/rejectwrites nothing. The suggestion is kept asrejected, and its author may suggest the key again.
Approving or rejecting an id your organization has no pending suggestion
under is 404 memory_suggestion_not_found: one already approved or
rejected, one in another organization, and one that never existed get the
same answer. See Memory for how
organization memory is recalled.
Workspaces
A workspace is a team's environment and spend budget inside an organization. Prompts and eval suites belong to the workspace a key names, and a workspace can carry a monthly spend cap. Every organization has a reserved default workspace. Workspace calls are for owners and admins.
curl https://api.cruxy.ai/api/v1/workspaces \
-H "Authorization: Bearer $CRUXY_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Production", "slug": "production", "spend_cap_micros": 5000000 }'const res = await fetch('https://api.cruxy.ai/api/v1/workspaces', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CRUXY_API_KEY}`,
'Content-Type': 'application/json',
},
// spend_cap_micros is in millionths of a US dollar: 5000000 is 5 USD a month.
body: JSON.stringify({ name: 'Production', slug: 'production', spend_cap_micros: 5000000 }),
})
if (!res.ok) throw new Error(`create failed: ${res.status} ${await res.text()}`)
const workspace = await res.json()
console.log(workspace.id, workspace.slug, workspace.spend_cap_micros, workspace.is_default)| Field | Meaning |
|---|---|
name | Required, 1 to 128 bytes. |
slug | A stable handle, derived from the name when omitted. One already used in the organization is 409 workspace_slug_exists, and default is reserved. It cannot be changed later. |
spend_cap_micros | An optional monthly ceiling in micro-USD, a positive integer. Omit it, or send null, for no cap. |
Chat enforces the cap against the workspace's summed cost: past it, a request
from a key in the workspace is 429 workspace_spend_cap_exceeded; see
Rate limits and budgets.
| Call | Does |
|---|---|
GET /api/v1/workspaces | Lists the organization's workspaces, the default first. |
GET /api/v1/workspaces/{id} | Returns one workspace. |
PATCH /api/v1/workspaces/{id} | Changes name, spend_cap_micros, or both. An explicit null cap removes the cap. |
DELETE /api/v1/workspaces/{id} | Deletes a workspace that has never held a key. One that has is 409 workspace_not_empty, and the default is 409 workspace_is_default. |
Next steps
- Standing rules: instructions that apply to every chat in the organization.
- Memory: what chat recalls from organization memory.
- Get your API key: the key that names your organization.
- API Reference: every organization operation with its exact request and response shape.