domain and that username as inputs. Things to know before you call:
- API access needs a plan. The JSON APIs require a Standard plan or above; on a free project they answer 401 “Your current subscription does not have access to this feature” (or 403).
ota.restoreis the exception: it works on a free project. - Every endpoint is scoped to one project. All requests go to
https://www.commcarehq.org/a/{domain}/.... There is no plugin-leveldomainorusernameoption: pass both on every call. - Two pagination styles. Most listings use
limitandoffsetwith ameta.total_count;cases.listpages oldest-to-newest by cursor: pass thenextCursorit answers ascursoruntilnextCursoris absent. - Async bulk actions.
forms.bulkActionaccepts up to 5000 form ids for archive, unarchive or permanent delete, and answers a job id; follow withforms.bulkActionStatusuntil status iscompleteorfailed.completedoes not mean every form succeeded: comparesucceededwithrequestedand readskipped. A form must be archived before it can be deleted. - Writes.
submissions.submitposts OpenRosa XForm XML to the receiver. HQ answers 201 even when it could not process the form; the call fails in that case (naturesubmit_errororprocessing_failure) and otherwise returns themessageand itsnature.users.createprovisions a worker account with an initial password. - Delete is permanent.
users.deleteremoves a worker account, andforms.bulkActionwith actiondeletepermanently removes forms. - OTA restore auth.
ota.restorepulls the full case-restore XML. The docs show worker Basic credentials, but HQ also accepts the ApiKey header and restores the account that owns the key, so a web user’s key returns that user’s restore, not a mobile worker’s. HQ puts the owner’s password hash in the restore’s registration block; the plugin replaces it with[removed]before returning the XML.
- 32 typed API operations
Setup
1
Install
2
Add the plugin
corsair.ts
multiTenancy: true, scope calls with corsair.withTenant(id). See Quick start for KEK + Hub keys, and Multi-tenancy for account isolation.3
Choose authentication
- API Key (Recommended)
No setup required yet. When you make your first request as a tenant, Corsair prompts for the API key.More: API Key
4
Connect a tenant
Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see Connect / OAuth.
Example API calls
List open cases of a typeWhat’s next
API reference
Every
commcare.api.* operation with input and output types.Connect / OAuth
createLink, Hub delivery, and tenant connect flows.
Use with agents
Expose this plugin’s operations as MCP tools.