Introduction to GraphQL
21 Travel Rule exposes its business logic through a single GraphQL schema. The same API powers the Compliance Dashboard and your own integrations.
Endpoints and transports
- HTTP requests are sent to
/graphqlusingPOSTwith a JSON body containing aquerystring and optionalvariables. - Subscriptions use the WebSocket endpoint
/graphql-ws, following the graphql-ws protocol. Both use the same schema and authentication model. - Authentication is required for all operations; use a Keycloak-issued bearer token as described in Authentication.
Example HTTP call:
curl -X POST https://yourvasp.intranet/graphql \
-H "Authorization: Bearer <access-token>" \
-H "Content-Type: application/json" \
--data '{"query":"query { trpd { vasps { name } } }"}'
How the schema is structured
- Root fields – The schema is namespaced by domain:
trpdcovers Travel Rule Protocol operations,aopdcovers address-ownership proofs, andautodexposes administrative data used by the Compliance Dashboard. - Queries fetch data (for example
trpd { vasps { name } }). - Mutations perform actions (for example
trpd { inquire(...) }to start a TRP flow ortrpd { confirmTx(...) }to submit a transaction hash). - Subscriptions stream updates (
trpdTransactionsandaopdProofsare the primary channels).
GraphQL validates every request against the schema, so you only receive fields that exist and match the declared types.
Arguments, variables, and selection sets
-
Arguments are passed directly to fields:
trpd { validateTravelAddress(input: "...") }. -
Use
variablesto keep queries reusable:{ "query": "query Check($address: String!) { trpd { validateTravelAddress(input: $address) } }", "variables": { "address": "taEJKtAQyrS5x6i59GBS2fcbbZDB9VM9r4yKeWR" } } -
Selection sets let you choose only the fields you need, which keeps responses small and stable even as the schema grows.
Discoverability and errors
- The API is fully introspectable. You can use GraphiQL to interactively explore the full API.
- GraphQL responses always return an
errorsarray alongsidedata. When a mutation fails validation or business rules, expecterrors[0].messageto contain the reason, whiledatais set tonullfor the failing field.