Skip to content
Last updated: 2026-04-10

Your First Request

This guide walks you through the two steps needed to call the Dxtra API: authenticate with your Personal Access Token (PAT) to get a JWT, then send a GraphQL query.

Prerequisites

  • A Dxtra account with a Personal Access Token. See Authentication for how to generate one.

Step 1: Exchange your PAT for a JWT

Personal Access Tokens are long-lived credentials that must be exchanged for a short-lived JWT access token before making API calls.

Bash
curl \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"personalAccessToken": "YOUR_PAT"}' \
  https://auth.dxtra.ai/v1/signin/pat
JavaScript
const response = await fetch('https://auth.dxtra.ai/v1/signin/pat', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ personalAccessToken: 'YOUR_PAT' })
});
const { session } = await response.json();
const accessToken = session.accessToken;
Python
import requests

resp = requests.post(
    'https://auth.dxtra.ai/v1/signin/pat',
    json={'personalAccessToken': 'YOUR_PAT'}
)
resp.raise_for_status()
access_token = resp.json()['session']['accessToken']

Response:

JSON
{
  "session": {
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "accessTokenExpiresIn": 3600,
    "refreshToken": "abc123..."
  }
}
  • accessToken — JWT valid for 1 hour (3600 seconds). Use this in the next step.
  • refreshToken — Valid for 12 hours. Exchange it via POST /v1/token to get a new access token without re-using your PAT.

Step 2: Send a GraphQL query

Use the JWT from Step 1 as a Bearer token in the Authorization header.

Bash
curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  --data '{"query": "query { dataControllers { id title } }"}' \
  https://api.dxtra.ai/v1/graphql
JavaScript
const query = `
  query {
    dataControllers {
      id
      title
    }
  }
`;

const response = await fetch('https://api.dxtra.ai/v1/graphql', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${accessToken}`
  },
  body: JSON.stringify({ query })
});
const { data } = await response.json();
Python
import requests

query = """
query {
  dataControllers {
    id
    title
  }
}
"""

resp = requests.post(
    'https://api.dxtra.ai/v1/graphql',
    headers={'Authorization': f'Bearer {access_token}'},
    json={'query': query}
)
resp.raise_for_status()
data = resp.json()['data']

Response:

JSON
{
  "data": {
    "dataControllers": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "title": "My Organisation"
      }
    ]
  }
}

Next steps