Admin API

Run a marketplace: listings, orders, shipping and members.

The Admin API is a GraphQL API. Send each operation as a POST request with a JSON body to this endpoint:

https://admin.api.district.net/graphql

Authentication

Each request sends a publishable client key in the District-Client-Authorization header. The key is safe to use in a browser. Reach out to your Enterprise account manager to get your key.

District-Client-Authorization: Bearer district_pk_live_…

To act for a signed-in buyer, also send the buyer's access token in the Authorizationheader. This header is optional. Without it, the API answers for a visitor who is not signed in, and viewer returns null.

Authorization: Bearer <user access token>

Client scopes

Some fields need a client key with a scope. The reference marks each of them with the label “Requires a client key with one of these scopes” and the list of scopes. A key with one of the listed scopes can read the field.

A scope on a type applies to every field of that type. A field that declares its own scopes uses only its own scopes.

Errors

An error in the errors list of the response has a code in extensions.code:

  • UNAUTHORIZED: The request has no valid client key. The HTTP status is 401.
  • FORBIDDEN: The key does not have a scope that the field requires. extensions.requiredScopes lists the scopes that allow it.
  • VALIDATION_ERROR: An argument is not valid, such as an ID of another type or a page size above 100. extensions.field names the argument.
  • PAGE_OUT_OF_RANGE: The after cursor points past the last page that the API returns.

Query limits

The API refuses an operation above one of these limits:

  • Depth: 15 levels of nested fields. Introspection queries are not counted.
  • Aliases: 30 in one operation.
  • Cost: 100,000 in one operation. A list field without first or last counts as 100 items.
  • Batches: 10 operations in one request.
  • Pages: 20 items by default, and at most 100 with first.

First request

This request reads the name and the handle of the marketplace that the key belongs to:

curl https://admin.api.district.net/graphql \
  -H 'District-Client-Authorization: Bearer district_pk_live_…' \
  -H 'Content-Type: application/json' \
  -d '{"query":"{ marketplace { name handle } }"}'

Read each field and type in the reference. To get a page as Markdown, send the header Accept: text/markdown with the request. llms.txt lists each page for language models.