| title | Introduction |
|---|---|
| sidebarTitle | Introduction |
| description | An overview of Plain's GraphQL API. |
Plain is built with this very GraphQL API we expose to you. This means that there are no limitations in what can be done via the API vs the UI.
These docs just highlight the most interesting and most used APIs. If you want to do something beyond what is documented here, please reach out to us or explore our schema on your own!
Our API is compatible with all common GraphQL clients with the following details:
- API URL:
https://core-api.uk.plain.com/graphql/v1 - Allowed method: POST
- Required headers:
Content-Type: application/jsonAuthorization: Bearer YOUR_TOKENwhere the token is your API key. See authentication for more details.
- JSON body:
query: the GraphQL query stringvariables: a JSON object of variables used in the GraphQL queryoperationName: the name of your GraphQL operation (this is just for tracking and has no impact on the API call or result)
If you'd like to use the GraphQL schema to generate types for your client code you can fetch the schema
from: https://core-api.uk.plain.com/graphql/v1/schema.graphql
In this example, we're going to get a customer in your workspace by their email address. You can find a customer's email on the right-hand side when looking at one of their threads in Plain.
You will need an API key with the customer:read permission. See authentication for details on how to get an API key
- `PLAIN_TOKEN`: The API key
- `PLAIN_CUSTOMER_EMAIL`: The email of the customer you want to fetch
```shell
PLAIN_TOKEN=XXX
PLAIN_CUSTOMER_EMAIL=XXX
curl -X POST https://core-api.uk.plain.com/graphql/v1 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $PLAIN_TOKEN" \
-d '{"query":"query customerByEmail($email: String!) { customerByEmail(email: $email) { id fullName updatedAt { iso8601 } } }","variables":{"email":"'"$PLAIN_CUSTOMER_EMAIL"'"},"operationName":"customerByEmail"}'
```