Make your first API request
The Vigil API is a GraphQL API at /api/graphql, on the same host as your Vigil console.
This page takes you from a new token to a working request.
1. Create a personal access token
Section titled “1. Create a personal access token”In the console, open Account settings → API tokens, choose Create token and copy the value when it is shown. Create an access token has the steps.
Keep the token in an environment variable or a secret store on a server or your own computer. Do not put it in JavaScript that runs in a browser, and do not commit it to source control.
2. Set your environment
Section titled “2. Set your environment”VIGIL_API_URL is the address of your Vigil console with /api/graphql in place of
/app.
export VIGIL_API_URL="https://next.vigilsecure.net/api/graphql"export VIGIL_API_TOKEN="vigil_pat_…"The Vigil skill for AI assistants uses the same two variables.
3. Ask Vigil who you are
Section titled “3. Ask Vigil who you are”curl --fail-with-body "$VIGIL_API_URL" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $VIGIL_API_TOKEN" \ --data '{"query":"query { identity { id displayName } }"}'A successful response has your account’s ID and name under data.identity:
{ "data": { "identity": { "id": "…", "displayName": "Thandi Nkosi" } } }If identity is null, the token is wrong, expired or revoked, or it belongs to a
different Vigil environment.
A GraphQL request can return HTTP 200 and still carry errors. Always check the errors
array in the response as well as the HTTP status.
The same request in TypeScript
Section titled “The same request in TypeScript”Run this on a server or as a local script, with the same two environment variables:
const url = process.env.VIGIL_API_URL;const token = process.env.VIGIL_API_TOKEN;if (!url || !token) throw new Error("Set VIGIL_API_URL and VIGIL_API_TOKEN");
const response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}`, }, body: JSON.stringify({ query: "query { identity { id displayName } }" }),});
if (!response.ok) throw new Error(`HTTP ${response.status}`);const result = await response.json();if (result.errors?.length) throw new Error(JSON.stringify(result.errors));if (!result.data?.identity) throw new Error("Token was not authenticated");console.log(result.data.identity);Explore the rest of the API
Section titled “Explore the rest of the API”The endpoint supports GraphQL introspection, so any GraphQL client can list the available
queries, mutations and subscriptions with their arguments. Opening /api/graphql in a
browser shows an interactive explorer.
The Vigil API explains permissions, token expiry and troubleshooting. If you would rather describe what you want in plain language, see Use Vigil with AI.