Client Orgs
Provision, list, and deprovision the isolated Wexio organizations behind your customers
Each of your customers gets its own Wexio organization, isolated from every other. These operations cover the lifecycle: create, list, and deprovision.
Scope: PARTNER_ADMIN. All three accept either an API key holding that scope or a member login on the provider org - which must be of kind TECH_PROVIDER either way. That kind is the sole identifier; there is no capability flag to check.
They act on your provider org, not on one client, so X-Wexio-Org plays no part here.
createClientOrg
createClientOrg(input: CreateClientOrgInput!): Organisation!API key or dashboard login.
Creates an isolated client org owned by your provider org, with partnerRelation: MANAGED.
partnerRelation: MANAGED is what makes an org your child: its usage rolls up to you and it has no retail plan of its own. An org that was only referred to Wexio is REFERRED, stays an ordinary retail customer, and is not a child. Only MANAGED counts.
If you pass an externalId that already belongs to one of your clients, the call fails with a 409.
Arguments - input: CreateClientOrgInput!
| Field | Type | Required | Description |
|---|---|---|---|
name | String! | Yes | Display name of the client org. |
slug | String | No | URL slug. Generated from name when omitted. |
externalId | String | No | Your identifier for this client. Echoed on every webhook as meta.externalId, so you can route events without a lookup. Set it. |
tenantDbUri | String | No | A MongoDB connection string for the client's own database. Omit it and the child inherits your provider org's tenantDbUri automatically. |
tenantRedisUrl | String | No | A Redis URL for the client. Same rule - omit it and the child inherits your provider org's. |
Bring Your Own Database
Both URIs are validated before the org is created, and the server opens a test connection first. A client org is never created pointing at infrastructure that does not answer.
| Rule | Detail |
|---|---|
| Schemes | mongodb:// or mongodb+srv:// for the database; redis:// or rediss:// for Redis. Anything else is rejected. |
| Hosts | Every host is resolved, including the targets behind an mongodb+srv record and the replica-set members the server advertises. Private, loopback, link-local and metadata addresses are rejected. |
| Mongo query options | Allowlisted. Common ones pass: authSource, replicaSet, retryWrites, w, readPreference, tls, timeouts, pool sizes, appName, compressors. Rejected: proxy*, tls*File, tlsInsecure, tlsAllowInvalid*, authMechanismProperties, srvServiceName, and any authMechanism other than SCRAM-SHA-1 or SCRAM-SHA-256. |
| Limits | At most 10 seed hosts or SRV records, at most 50 advertised members, and a 15-second probe deadline. |
| Blank or omitted | Inherits your provider org's URIs. |
| Shared infrastructure | A URI pointing at Wexio's own shared database or Redis is refused with a generic 400, including host aliases of it. |
A rejected URI returns a generic error with no addresses in it, so the endpoint cannot be used to probe networks. Debug the connection string on your own infrastructure rather than from the error text. If a legitimate option of yours is refused, raise it with Wexio rather than working around it.
While a Database Move Is Open
When a client's database is being moved, createClientOrg and deprovisionClientOrg return 409 for the affected orgs until the move finishes. A 409 caused by an open move carries the id at extensions.response.relocationId, so you can act on it without a lookup.
To check before acting, rather than discovering it from a 409:
query Pending {
openTenantRelocation(orgId: "<org id>") {
id
status
createdAt
members { organisationId name status }
}
}null means nothing is open. It is also what a caller outside the move gets, so the two cannot be told apart. members is scoped to the caller: the provider's OWNER or ADMIN sees every org in the move, and a client org's own OWNER or ADMIN sees only its own row. This query is member login only and never returns a connection URI.
Checking a Client's Own Infrastructure
An org with its own database or Redis exposes tenantConnection:
tenantConnection: {
database: TenantDatabaseStatus! // SHARED | CONNECTED | DISCONNECTED
redis: TenantRedisStatus! // SHARED | CONNECTED | DISCONNECTED
checkedAt: Date
reason: String
}null means the org runs on shared infrastructure. The field is readable only by the org itself - its own members or its own API key. Anyone else, including a provider reading its child, gets null.
Returns Organisation! - the created org. Useful fields:
| Field | Type | Description |
|---|---|---|
_id | String! | The org ID. This is the value you send as X-Wexio-Org. |
name | String! | Display name. |
slug | String! | URL slug. |
externalId | String | Your identifier, as supplied. |
partnerOf | String | Your provider org's ID. |
partnerRelation | PartnerRelation | MANAGED for orgs created this way. |
Tenant storage is inherited, not blank. A MANAGED child inherits the provider org's tenantDbUri and tenantRedisUrl, so a provider on its own cluster gets every client on that cluster without passing anything. Set them explicitly only when a specific client needs its own storage, for data-residency reasons for example.
Once created, an API key on your provider org acts on this client by naming its _id in X-Wexio-Org - see Authentication.
Organisation has no createdAt field, so a client-org row carries no creation timestamp. Record the time on your side if you need it.
A key sees a deliberately narrow organisation. Commercial and account fields (billing address, plan, usage credits, referral and lead source, onboarding data, the partner contract and its billing, invite code, coupon policy, and the member list) always read as null for an API key. Ask only for the fields above.
Example
mutation CreateClientOrg {
createClientOrg(input: {
name: "Pizzeria Roma"
externalId: "crmco-client-5541"
tenantDbUri: "mongodb+srv://…/roma"
}) {
_id
name
slug
externalId
partnerRelation
}
}{
"data": {
"createClientOrg": {
"_id": "6716b2f0a1c34d0012ab89ef",
"name": "Pizzeria Roma",
"slug": "pizzeria-roma",
"externalId": "crmco-client-5541",
"partnerRelation": "MANAGED"
}
}
}createClientOrgWithWebhook
createClientOrgWithWebhook(
input: CreateClientOrgInput!
webhook: ClientOrgWebhookInput!
): CreatedClientOrgWithWebhook!Creates a client org and a webhook subscription bound to it, in one call. input is the same as createClientOrg, which is itself unchanged.
Returns CreatedClientOrgWithWebhook! - organisation and webhook { id signingSecret }.
mutation Provision {
createClientOrgWithWebhook(
input: { name: "Acme Ltd", externalId: "crm-4821" }
webhook: {
url: "https://api.crmco.com/wexio/acme"
events: [MESSAGE_INBOUND_CREATED]
}
) {
organisation { _id }
webhook { id signingSecret }
}
}The signing secret appears only in this response. There is no way to read it afterwards, and rotating is the only alternative. Store it before you do anything else with the result.
If the webhook step fails after the org has been created, the org is kept and the error tells you which one: extensions.childOrganisationId carries the new child's id, and the original error code is preserved so you can still tell what went wrong.
Recover by calling registerPartnerWebhook with organisationIds: [childOrganisationId]. Retry the subscription only - calling this mutation again would create a second client org.
Outbound Auth Is Mandatory
An outbound webhook with no authentication - outboundAuthType of NONE, or a URL with none set - is refused with a 400 for tech providers and for their managed children. Pick HMAC, BEARER or BASIC.
Updates that only pause a connection still work, so you can always stop deliveries without first configuring auth.
clientOrgs
clientOrgs: [Organisation!]!API key or dashboard login.
Lists every client org your provider org manages. Takes no arguments and is not paginated. For large lists, clientOrgsPage(pagination, filter) returns the same orgs in cursor pages, with filter.search to narrow by name.
Returns [Organisation!]! - same type as above.
Example
query ListClientOrgs {
clientOrgs {
_id
name
externalId
partnerRelation
}
}{
"data": {
"clientOrgs": [
{
"_id": "6716b2f0a1c34d0012ab89ef",
"name": "Pizzeria Roma",
"externalId": "crmco-client-5541",
"partnerRelation": "MANAGED"
}
]
}
}deprovisionClientOrg
deprovisionClientOrg(orgId: String!): OrganisationCleanupResult!API key or dashboard login.
Tears a client down: disconnects its channels, deletes its Wexio-side data, and then emits organisation.deleted to your webhook.
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
orgId | String! | Yes | The client org to deprovision. Must be one of your managed clients, otherwise the call fails with a 403 Not a managed client of this partner. |
Returns OrganisationCleanupResult!
| Field | Type | Description |
|---|---|---|
success | Boolean! | true when the cascade completed without errors. |
organisationId | String! | The org that was torn down. |
deletedCounts | CleanupDeletedCounts! | Per-collection delete counts. ~50 integer fields - request only the ones you care about. |
errors | [String!]! | Non-fatal problems hit during the cascade. Empty on a clean run. |
duration | Int! | How long the cascade took, in milliseconds. |
Commonly requested deletedCounts fields: messages, chats, conversations, people, integrations, media, flows, webhookConnections.
deprovisionClientOrg is destructive and not reversible. It disconnects the client's channels and deletes their data on Wexio's side.
Example
mutation Deprovision {
deprovisionClientOrg(orgId: "6716b2f0a1c34d0012ab89ef") {
success
organisationId
duration
errors
deletedCounts { messages chats conversations people integrations }
}
}{
"data": {
"deprovisionClientOrg": {
"success": true,
"organisationId": "6716b2f0a1c34d0012ab89ef",
"duration": 4182,
"errors": [],
"deletedCounts": {
"messages": 12480,
"chats": 311,
"conversations": 311,
"people": 297,
"integrations": 2
}
}
}
}organisation.deleted is emitted only after the delete succeeds. If the cleanup aborts, you do not receive it.
Related
- Webhook Subscriptions - register the endpoint that receives client events
- Usage - what your clients have consumed
- Billing - how client usage is charged to you
- Authentication -
X-Wexio-Organd bound keys