Use GraphQL
Middesk provides an optional GraphQL API for accessing business verification and identity data. It enables you to query the business identity, associated people, addresses, and other related compliance and risk insights through a flexible GraphQL interface. Unlike traditional REST APIs, which often use multiple endpoints for different resources and operations, GraphQL centralizes all interactions through a single endpoint. Interaction with the API is via GraphQL queries and mutations. The queries provide an interface to return only the fields requested.
Use of the GraphQL API is optional and contains a subset of all available functionality. It can offer some benefits, but use the traditional REST API if it better suits your use case.
The GraphQL endpoint at Middesk is: https://api.middesk.com/graphql
The public schema reference is available on Apollo Studio.
Authentication
Send your API credentials in the Authorization header as a Bearer Token.
Example request:
Get Started
Using GraphQL
We recommend using a GraphQL client to introspect and explore the full schema. An API key can be used to interact with the API on Apollo Studio, which also can be used to view the lastest version of the schema. Our webhook behavior matches our REST API webhook design.
IDs and timestamps
- IDs use the GraphQL
IDscalar - Timestamps are ISO8601.
- Fields marked with
!are non-nullable in the schema.
Queries
Retrieve by ID
With people
With addresses and website
With TIN and formation
Connection-based pagination (relay-style)
Lists are returned as “connections” (for example, people, names, addresses, businesses). Connections support cursor-based pagination via:
first/afterfor forward paginationlast/beforefor backward pagination
Each connection includes:
edges { cursor node { ... } }nodes { ... }(convenience)pageInfo { hasNextPage hasPreviousPage startCursor endCursor }
Page-size limits
To keep responses predictable, paginate within these limits:
- list: 25 per page
- nested list: 10 per page
If you request more than the limit, results may be clamped.
Forward pagination example:
This pattern is already supported across connections.
Mutations
To create a new business, use a mutation:
The mutation will create a new business and return its id, name, and status. Use the errors field to check for any issues creating the business. if a business fails to create, it will return as null with errors present.
A common use case after creating a business is to add additional orders. The createOrder mutation can be used for this purpose.
Errors
Middesk’s GraphQL API follows the standard GraphQL error format, returning errors within an errors array in the response. Each error object includes a message describing what went wrong.
Always check for the errors array before assuming success—GraphQL queries can partially succeed with a 200 HTTP status, returning some data while including errors for failed fields. Monitor HTTP status codes for server errors (5xx). Use strongly-typed GraphQL clients when possible to catch validation errors at development time, and always validate required fields to avoid runtime null value errors.
System Level Errors
System-level errors indicate that the GraphQL request could not be executed normally. These errors appear in a top level errors array.
Mutation Level Errors
For business logic or validation failures within a mutation, the API does not use the top level errors array. Instead, each mutation returns a result payload that may contain errors within an errors field describing the specific failures.
REST API vs. GraphQL API
The following example demonstrates the differences between using Middesk’s REST API and its GraphQL API.
REST API
Retrieving a business
Sending a GET request tohttps://api.middesk.com/v1/businesses/{id} retrieves the business for the given identifier (id).
The returned response consists of the entire business payload with all attributes.
While simple to use, the payload contains more data than may be needed, depending on the use case. Interacting with the API necessitates navigating a large payload to find relevant information.
GraphQL API
Retrieving a business
Send a POST request to https://api.middesk.com/graphql with the following GraphQL query to retrieve a business.
Via curl:
The following response is returned with only the requested attributes.
Another example
The GraphQL API supports fetching only the data needed. For example, a user can check only the name and address verification outcomes of a business by using the following GraphQL query:
The following response is returned with only the requested attributes.
The GraphQL API allows users to fine-tune their usage of Middesk’s product.