Skip to main content

Developer quickstart

Owlie's API is one GraphQL endpoint on your own Owlie domain. A request authenticates with an API key, and the key acts as a service account. The key can do what that service account's roles allow, the same way a person signed in to the dashboard can do what their roles allow.

Find your endpoint​

Every Owlie organization has its own host name, the one you sign in at, such as acme.owlie.com. The API lives on that host:

POST https://acme.owlie.com/api/graphql

Owlie reads the organization from the host name before it checks the key, so a key works only on the domain of the organization that created it.

Create an API key​

Creating a key needs the api_key.modify permission.

  1. Open Admin > Tenant Settings > API Keys and select Create API key.
  2. Enter a Service account name. Owlie creates a new service account with that name, and the key belongs to it. Expiration date and time (optional) sets when the key stops working. For a key that never expires, leave it empty.
  3. Select Create API key and copy the key from API key created. Owlie shows it only once.

A new service account has no roles, so the key can authenticate but can read almost nothing yet. API keys and service-account access covers managing and revoking keys.

Send a first request​

Send the key in the Authorization header with the Owlie scheme. myProfile returns the identity the request runs as and needs no role, which makes it a good first call.

export OWLIE_DOMAIN="acme.owlie.com"
export OWLIE_API_KEY="<your API key>"

curl -X POST "https://$OWLIE_DOMAIN/api/graphql" \
-H "Authorization: Owlie $OWLIE_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "query": "query WhoAmI { myProfile { id display_name type status } }" }'

The response names the key's service account:

{
"data": {
"myProfile": {
"id": "019d1f36-0000-7000-8000-000000000041",
"display_name": "reporting-job",
"type": "SERVICE_ACCOUNT",
"status": "ACTIVE"
}
}
}

The same request from TypeScript or JavaScript, with no library:

const response = await fetch(`https://${process.env.OWLIE_DOMAIN}/api/graphql`, {
method: "POST",
headers: {
authorization: `Owlie ${process.env.OWLIE_API_KEY}`,
"content-type": "application/json",
},
body: JSON.stringify({
query: "query WhoAmI { myProfile { id display_name type status } }",
}),
});

const { data, errors } = await response.json();

Authorization: Bearer <key> works as well as Authorization: Owlie <key>.

If the key is missing, wrong, expired or revoked, or its service account is disabled, Owlie answers 401 with { "message": "Not Authorized" } and runs nothing.

Give the service account roles​

Owlie authorizes every GraphQL operation against the caller. Now try a read that needs a permission:

query FirstIdentities {
identities(first: 5) {
data {
id
display_name
email
}
}
}

With no roles, the request authenticates and the operation is refused. The HTTP status is 200 and the refusal is in errors:

{
"errors": [
{
"message": "Not authorized for identity.read",
"extensions": { "code": "OwlieError", "status": 403 }
}
],
"data": null
}

The message names the missing permission. Assign the service account a role that holds it: open the role in Admin > Directory > Roles and assign it to the service account's identity. The role and permission reference lists what each role allows. The key stays the same when the service account's roles change.

Give a service account the smallest set of roles its job needs. A key cannot act as another person: it is always its own service account.

Where to go next​