Skip to content

Make a GraphQL request ​

This example sends a Platform API query with the authenticated user's bearer token. Read authentication before choosing an endpoint and credential.

HTTP example ​

bash
curl https://api.agiodigital.com/graphql \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_USER_ACCESS_TOKEN" \
  --data '{"query":"query ConnectionCheck { __typename }"}'

TypeScript example ​

ts
const response = await fetch("https://api.agiodigital.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${userAccessToken}`
  },
  body: JSON.stringify({
    operationName: "ConnectionCheck",
    query: "query ConnectionCheck { __typename }",
    variables: {}
  })
});

if (!response.ok) {
  throw new Error(`GraphQL request failed with HTTP ${response.status}`);
}

const result = await response.json();

if (result.errors?.length) {
  throw new Error("The GraphQL operation failed");
}

const data = result.data;

userAccessToken is the token from your platform user session. A successful HTTP response does not guarantee a successful GraphQL operation. Check the returned errors and the result fields defined by the operation.

Task examples ​

Choose an operation from the schema browser, or start with a task guide: