Getting started
Learn more about forming requests and the responses you will receive from the API.
GraphQL API is an alternative to a traditional REST API, but operates in a similar way. To execute a query, make a POST request to the GraphQL endpoint (see endpoints).
The GraphQL request body is composed of three parts. The GraphQL query document is embedded in the request as a string, under the field named query
. Which query to execute is indicated by the optional operationName
field. This field must be provided if the query document has multiple queries or mutations, to specify which query or mutation to execute. Finally, if the query defines any variables then include them as a map under the variables
field.
Here's a simple request to execute a query which includes argument values for variables defined in the query. GetPatient
is the optional (because there is only one query) operationName
we have specified.
- json
01{02 "query": "query GetPatient($patient_id: String!) {03 patient(id: $patient_id) {04 patient {05 id06 profile {07 first_name08 last_name09 }10 }11 }12 }",13 "variables": {14 "patient_id": "ExamplePatientId"15 }16}
If you're sending a request via curl or HTTP, send the query with your API key in a JSON string.
- bash
01curl -X POST \02 'https://api.sandbox.awellhealth.com/orchestration/m2m/graphql' \03 -H "Content-Type: application/json" \04 -H 'apiKey: YOUR_API_KEY' \05 -d '{"query":"query GetPublishedPathwayDefinitions{publishedPathwayDefinitions{publishedPathwayDefinitions{id title}}}"}'
Interact with the Awell API quickly with our Postman collection.
Explore our GraphQL API using the interactive GraphiQL explorer.
The response is composed of a data
section and an error
section. The data
section contains the response to the requests query. Any errors that occur during the execution of the request are included in the error
section.
- graphql
01query GetPatient($patient_id: String!) {02 patient(id: $patient_id) {03 code04 success05 error {06 code07 message08 }09 patient {10 id11 profile {12 name13 }14 }15 }16}
See also Status Codes and Error Responses.