Capabilities
The reverse direction: an endpoint you publish so App Center can ask you a question only you can answer.
A webhook pushes a change to you. A capability is the same arrangement in the other direction: a standard endpoint you expose, which App Center calls when a question can only be answered by you. One contract per capability, one declaration per application, no per-app branch anywhere in App Center.
The three contracts
assigned-apps- Kindquery
- Rev2
- The questionWhich accounts and people does this App Center user hold a membership for in your product?
account-deletion- Kindboth
- Rev1
- The questionWhich deletion requests are open, and may App Center move one through your states?
membership-leave- Kindcommand
- Rev1
- The questionThis person is giving up one of the memberships you reported. Remove it, and keep what they did.
Kind decides the traffic, not the code. A query is a GET fanned out to every application that declared it and merged with sources; a command is a POST addressed to the one application whose data changes. account-deletion is both, and its POST dispatches on operation: update-status is addressed, while create-request is fanned out to every declarer because every one of them holds data the deletion has to reach. membership-leave is the command: App Center knows the membership exists but only you can remove your own row, so the call goes to you alone and your answer goes straight back to the person.
Registering the endpoint
GET /apps/:appId/capabilities- EffectEvery platform capability, declared or not. An undeclared one comes back with version 0
PUT /apps/:appId/capabilities/:capability- EffectDeclare or edit the endpoint that answers it. Version required once declared
POST /apps/:appId/capabilities/:capability/test- EffectCall it for one real user and record the HTTP outcome and rejection reason. A
commandcannot be exercised by a read, so it answers409
The request you receive
Authorization- ValueBearer service token minted for your audience — no user identity, no cookie
X-AppCenter-Capability- ValueWhich contract is being asked
X-AppCenter-Contract-Version- ValueThe revision being asked for. Refuse one you do not implement rather than guessing
X-AppCenter-Request-Id- ValueCorrelates your log line with the outcome recorded on the declaration
export async function GET(request: Request) {
// One endpoint can serve several revisions; refuse the ones you do not have.
const version = request.headers.get("x-appcenter-contract-version");
if (version !== "2") {
return Response.json(
{
success: false,
error: {
code: "UNSUPPORTED_CONTRACT_VERSION",
message: "Only contract revision 2 is supported",
},
},
{ status: 400 },
);
}
const userUuid = new URL(request.url).searchParams.get("userUuid");
if (!userUuid) {
return Response.json(
{
success: false,
error: { code: "VALIDATION_FAILED", message: "userUuid is required" },
},
{ status: 400 },
);
}
const memberships = await membershipsFor(userUuid);
if (memberships.length === 0) {
// An empty answer is a valid answer, and it beats an error.
return Response.json({ success: true, data: { memberships: [] } });
}
return Response.json({
success: true,
data: {
memberships: memberships.map((membership) => ({
shortCode: SHORT_CODE, // must be your own registered code
membershipKey: membership.id, // your row id, not the person's
account: {
uuid: membership.accountUuid,
name: membership.businessName,
email: membership.billingEmail ?? null,
phone: membership.phone ?? null,
address: membership.address ?? null,
imageUrl: membership.logoUrl ?? null,
},
person: {
uuid: membership.user.appcenterUuid,
name: membership.user.name,
email: membership.user.email,
imageUrl: membership.user.image,
},
// Appended to your webUrl when this membership is launched.
launchParams: {
au: membership.accountUuid,
uu: membership.user.appcenterUuid,
},
})),
},
});
}assigned-apps
{endpointUrl}?userUuid=…Your audience · client_credentialsWhich accounts and people this App Center user holds a membership for in your product. Fanned out to every declarer and merged.
Headers
- Authorization
Bearer <service token minted for your audience>- `X-AppCenter-Capability`
assigned-apps- `X-AppCenter-Contract-Version`
2— refuse a revision you do not implement- `X-AppCenter-Request-Id`
- Correlation id; log it beside your own request id
Parameters
userUuidstring · queryrequired- The App Center user uuid. Never infer the subject from the service token — it has no
sub.
{
"success": true,
"data": {
"memberships": [
{
"shortCode": "VPOS",
"membershipKey": "9a2c…",
"account": {
"uuid": "3d1f…",
"name": "Ama's Shop",
"email": "billing@example.com",
"phone": "+233 24 000 0000",
"address": "12 Oxford Street, Accra",
"imageUrl": "https://cdn.retill.app/logo.png"
},
"person": {
"uuid": "8f14…",
"name": "Ama Mensah",
"email": "ama@example.com",
"imageUrl": "https://cdn.retill.app/avatar.png"
},
"launchParams": { "au": "3d1f…", "uu": "9a2c…" }
}
]
}
}[] is a valid answer and beats an error — the caller simply sees no extra rows. A membership is the tenant, the person and your launch parameters; nothing else is read.
Failures to handle
- 400
unsupported_contract_version - You do not implement the revision in
X-AppCenter-Contract-Version. Refuse it rather than guessing.
shortCodemust be your own registered code, compared case-insensitively. An entry naming another application fails the whole response.account.uuid,person.uuidandmembershipKeyare required: which business, which human, and which of your rows. None can stand in for another.membershipKeyis your membership id, never the person's — one person holds several memberships, and a repeated key hides one of them.- At least one of
person.name/person.emailmust be present, or there is nothing to render. - All-or-nothing: one malformed entry discards your entire answer; it is never shown partially.
- A refusal is a verdict — answer a non-2xx status, or
{ "success": false, "error": { "code": "why_not", "message": "why" } }. Branching onsuccessis the whole protocol; there is no second flag. - The call must be a cheap read. App Center may make it on any page load that needs the answer: no writes, no email.
memberships- Requiredyes
- ShapeArray of entries. Every row is validated together
shortCode- Requiredyes
- ShapeYour own registered short code
membershipKey- Requiredyes
- ShapeYour own membership row id. Opaque: echoed back, never parsed, unique within your answer
account- Requiredyes
- Shape
{ uuid, name, email, phone, address, imageUrl }—uuidis the App Center account, the rest display only person- Requiredyes
- Shape
{ uuid, name, email, imageUrl }—uuidis the App Center user, the rest display only launchParams- Requiredno
- ShapeFlat
Record<string, string>, defaults to{}. At most 10 entries, keys matching^[A-Za-z][A-Za-z0-9_.-]{0,63}$, values of 1–512 characters
launchParams is your declaration, not a platform mode
App Center owns the catalogue entry and its webUrl; it does not know what a launch means inside your product. Declare the parameters and App Center appends them verbatim when it launches this membership — { "au": "…", "uu": "…" } becomes https://pos.example.com/dashboard?au=…&uu=…. Empty values are dropped, and a credential name (access_token, id_token, refresh_token, token, password, api_key, apikey, secret) rejects the answer. An application that needs no context simply omits the field.
account-deletion — the read
{endpointUrl}?status=…Your audience · client_credentialsWhich deletion requests you hold, optionally filtered by the platform's status vocabulary.
Headers
- `X-AppCenter-Capability`
account-deletion- `X-AppCenter-Contract-Version`
1
Parameters
statusstring · querypending_admin_review,contacted,cancelled,dismissed,scheduled_for_deletion,restored,deletion_due,deletion_in_progress,deletion_failed,permanently_deleted.
{
"success": true,
"data": {
"requests": [
{
"uuid": "9a2c…",
"email": "ama@example.com",
"userUuid": "8f14…",
"userName": "Ama Mensah",
"reason": "not_using",
"reasonLabel": "I no longer use it",
"details": null,
"contactPhone": null,
"status": "scheduled_for_deletion",
"requestedAt": "2026-10-02T09:00:00.000Z",
"reviewedAt": "2026-10-03T11:20:00.000Z",
"resolvedAt": null,
"gracePeriodEndsAt": "2026-11-02T11:20:00.000Z",
"adminNote": null,
"statusHistory": [
{
"fromStatus": "pending_admin_review",
"toStatus": "scheduled_for_deletion",
"changedAt": "2026-10-03T11:20:00.000Z",
"changedBy": "admin",
"changedByEmail": "ops@versified.com.gh",
"note": null
}
]
}
]
}
}Failures to handle
- 400
unknown_status - You returned a status word App Center cannot draw. It fails the response rather than rendering a blank cell.
statusmust come from the platform's vocabulary — inventing a word fails the whole answer.- Timestamps are ISO-8601.
statusHistoryis how the operator sees what your state machine did.
account-deletion — the writes
{endpointUrl}Your audience · client_credentialsTwo operations on one route. create-request is fanned out to every declarer; update-status is addressed to the one that holds the row.
Headers
- `Content-Type`
application/json- `X-AppCenter-Capability`
account-deletion- `X-AppCenter-Contract-Version`
1
Request body
operationstringrequiredcreate-requestorupdate-status. Everything else in the body depends on which one it is.email, userUuid, userName, reason, reasonLabel, details, contactPhonestrings · create-request- The person's own submission. Echo it into your table, starting in whatever status means "we have it".
requestUuid, status, adminNote, adminEmailstrings · update-statusrequiredrequestUuidis your ownuuid;statusis one word from the platform vocabulary;adminEmailis who acted — record it in your audit trail.
{
"operation": "create-request",
"email": "ama@example.com",
"userUuid": "8f14…",
"userName": "Ama Mensah",
"reason": "not_using",
"reasonLabel": "I no longer use it",
"details": null,
"contactPhone": null
}{
"operation": "update-status",
"requestUuid": "9a2c…",
"status": "contacted",
"adminNote": "Called the customer",
"adminEmail": "ops@versified.com.gh"
}{
"success": true,
"data": {
"request": {
"uuid": "9a2c…",
"status": "pending_admin_review",
"email": "ama@example.com",
"userUuid": "8f14…",
"statusHistory": []
}
},
"message": "Account deletion request created."
}The full request is required on update-status — the operator must see the row that actually changed.
- Creating is idempotent: if the person already has a request in a blocking status, answer
success: truewith that existing row rather than a second one. - A create is a write, so send your own acknowledgement email. App Center sends its own as well.
- Refuse a transition your state machine does not allow with
{ "success": false, "error": { "code": "INVALID_TRANSITION", "message": "why" } }. Never silently no-op. - A failed
create-requestis recorded against the declaration's health instead of failing the person's submit — the receiver still holds their data.
membership-leave
{endpointUrl}Your audience · client_credentialsThis person is giving up one membership you reported. Remove it, keep everything they did, and answer what happened.
Headers
- `Content-Type`
application/json- `X-AppCenter-Capability`
membership-leave- `X-AppCenter-Contract-Version`
1
Request body
userUuidstringrequired- The person, taken from App Center's session — never from their own request. It is the same uuid you receive on
assigned-apps. membershipKeystringrequired- Exactly the
membershipKeyyou sent inassigned-apps. Opaque to App Center: echoed back, never parsed.
{
"userUuid": "8f14…",
"membershipKey": "us-4471"
}{
"success": true,
"data": { "membershipKey": "us-4471", "left": true, "alreadyLeft": false }
}{
"success": true,
"data": { "membershipKey": "us-4471", "left": true, "alreadyLeft": true }
}left describes the state, not the transition. A retry after a successful leave is this answer, never a refusal: a person who taps twice must not be told they failed.
{
"success": false,
"error": {
"code": "REQUEST_FAILED",
"message": "The account owner cannot leave their own account"
}
}A refusal is a verdict: nothing changed, and the person reads your message instead of a failure.
Failures to handle
- 422
REQUEST_FAILED - The key is not this person's, the row is an owner, or your own policy forbids the leave.
- Never answer
5xxfor a policy decision. A5xxsays your application is broken, and the person is told the leave could not be confirmed rather than that it was refused. - Verify ownership before removing anything.
userUuidnames the person,membershipKeynames their row. - Keep history, drop access: remove or soft-delete the membership, and leave the sales, orders and audit rows attributed to the person where they are.
- Only a confirmed answer removes the card from My Apps. Anything else leaves it in place, so the next read has to tell the truth on its own.
What App Center does with it
A read is merged across every declarer and stamped with attribution, so the caller can tell which application produced which row. The operator endpoint is the only one that shows the per-application report.
{
"success": true,
"data": {
"userUuid": "8f14…",
"memberships": [
{
"appId": 12,
"shortCode": "VPOS",
"membershipKey": "us-4471",
"account": {
"uuid": "3d1f…",
"name": "Ama's Shop",
"email": "billing@amasshop.test",
"phone": null,
"address": null,
"imageUrl": null
},
"person": {
"uuid": "8f14…",
"name": "Kojo Boateng",
"email": "kojo@amasshop.test",
"imageUrl": null
},
"launchParams": { "au": "3d1f…", "uu": "us-4471" },
"owner": {
"uuid": "3d1f…",
"name": "Ama Mensah",
"email": "ama@amasshop.test",
"imageUrl": null
},
"canLeave": true
}
],
"sources": [
{
"appId": 12,
"appName": "Retill",
"shortCode": "VPOS",
"status": "ok",
"httpStatus": 200,
"durationMs": 84,
"count": 1,
"message": null
},
{
"appId": 19,
"appName": "OneKitchen",
"shortCode": "ONEKITCHEN",
"status": "error",
"httpStatus": 502,
"durationMs": 31,
"count": 0,
"message": "Receiver answered 502: upstream unavailable"
}
]
}
}membershipsis the concatenation of the conforming entries, each stamped with theappIdand the _registered_shortCodeof the application that produced it.membershipKeyis echoed untouched.owneris the one field you never send: App Center resolves it onaccount.uuidfrom its own users, so it is the account's owner whichever application reported the membership — andnullwhen that account has no App Center user row. Return it and the validator drops it.canLeaveis App Center's too:trueonly where you declaredmembership-leaveand this person is not the account owner. It is what puts the leave on the My Apps card, so declaring the capability is what turns it on.sourcesis the per-application report: status, HTTP outcome, duration, row count and the refusal message. It is how a broken declarer becomes visible.- A failed declarer does not fail the whole query — its outcome is recorded against the declaration, and the user-facing endpoint simply omits its rows.
- The admin test route is the fastest way to prove a declaration end to end, because it uses a real user and stores the result — and it answers what you returned, without
owner.
Adding a second implementation is configuration
Nothing in the platform names an application. A new declarer of an existing capability becomes part of the answers as soon as its endpoint passes the test — no App Center release, no fan-out list to edit.
Something here out of date or unclear?
The platform team answers integration questions directly.
