How to use the API
Owlie's API is GraphQL over HTTPS. Every operation goes to one endpoint on your organization's own domain, authenticates with an API key, and is authorized against the roles of the key's service account. This page describes what all operations have in common. The examples show complete operations, and the schema reference lists every field.
Send a request
Send a POST to /api/graphql on the host name you sign in to Owlie at:
curl -X POST "https://acme.owlie.com/api/graphql" \
-H "Authorization: Owlie $OWLIE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "query Identity($id: ID!) { identity(id: $id) { id display_name email } }",
"variables": { "id": "019d1f36-0000-7000-8000-000000000005" }
}'
The JSON body has three properties:
| Property | Required | Holds |
|---|---|---|
query | yes | The GraphQL document: a query or a mutation. |
variables | no | An object with a value for each variable the document declares. |
operationName | no | The operation to run, when the document holds more than one. |
A body larger than 6 MB is refused with status 413 before Owlie reads the document.
The response is JSON with data, errors or both. Read errors first: a request that Owlie
authenticates and then refuses answers status 200 with the refusal in errors.
Errors and API limits lists the error codes and the limits on a
document's size and depth.
Authenticate
Send an API key in the Authorization header:
Authorization: Owlie <key>
Authorization: Bearer <key> is accepted too. A key belongs to one organization and to one service
account in it. Owlie finds the organization from the request's host name, so send the request to the
domain that created the key.
Owlie answers 401 with the body { "message": "Not Authorized" }, and runs nothing, when:
- The header is missing or is not
Owlie <key>orBearer <key>. - The key does not exist in that organization, or has been revoked.
- The key has passed its expiry date.
- The key's service account is disabled.
The developer quickstart walks through creating a key.
Authorization
A key never carries permissions of its own. It authenticates as its service account, and Owlie checks each operation in the document against that identity. A key cannot act as another person.
Fields are authorized in one of three ways:
- By permission. Most fields need a permission that a role grants:
identitiesandidentityneedidentity.read,resourcesneedsresource.read,createBulkJobneedsidentity.modify. A caller without it gets an error whose message names the permission, such asNot authorized for resource.read. - By caller. Fields that return the caller's own data need no role:
myProfile,myRequests,myTickets,myClaimedTicketsandmyReviewItemsanswer for the identity the request runs as. - By relationship. Some fields decide per object.
requestreturns a request the caller is a party to, or any request when the caller hasrequest.read.createRequestlets a caller request access for itself, and needsrequest.modifyto request for an arbitrary identity.
Roles are assigned to the service account's identity in the dashboard. API keys and service-account access and the role and permission reference cover that side.
POST https://acme.owlie.com/api/graphql
Authorization: Owlie <key>
query { identities(first: 5) { data { id display_name } } }- 01Host nameOrganization foundOwlie reads the organization from acme.owlie.com before it looks at the key.
- 02API keyService accountThe key resolves to its service account, and the request runs as that identity.
- 03OperationPermission missingidentities needs identity.read, and none of the service account's roles grants it.
In short, a bad credential stops the request with 401 before anything runs, and a missing permission
answers 200 with a 403 error entry. Both are different from a request that succeeds with an
empty result.
Variables
Declare variables in the operation and send their values in variables. Don't build a document by
joining strings with values in it.
query ActivePeople($filter: JSONObject, $first: Int, $after: String) {
identities(filter: $filter, first: $first, after: $after, sort: { column: "display_name", direction: ASC }) {
data {
id
display_name
email
department
}
pageInfo {
hasNextPage
nextCursor
}
}
}
Variables:
{
"filter": { "status": "ACTIVE", "department": "Finance" },
"first": 100
}
Identifiers are UUIDs, passed as strings. Field and argument names follow the schema exactly, which
mixes snake_case (display_name, request_number) and camelCase (pageInfo, requestResources).
The schema's custom scalars are DateTimeISO (an ISO 8601 timestamp), Date, UUID, JSON and
JSONObject.
Filter and sort a list
List fields that take filter: JSONObject read Owlie's filter syntax: an object whose keys are field
names. A plain value means equals, and several keys must all match.
{ "status": "ACTIVE", "department": "Finance" }
For other comparisons, give the field an object of operators:
| Operator | Matches when the field |
|---|---|
$ne | is not equal to the value |
$gt, $gte, $lt, $lte | is greater or less than the value |
$in, $nin | is, or is not, one of the listed values |
$like, $ilike | matches a pattern where % stands for any text. $ilike ignores case |
$null | is empty (true) or set (false) |
$containsAll, $containsAny | is a list holding all, or any, of the listed values |
$jsonContains | is a JSON value containing the given object |
$beforeNow, $afterNow | is a date before or after now (true) |
$olderThan, $newerThan, $withinNext | is a date relative to now, given as { "days": n } or { "weeks": n } |
Combine conditions with one $and or $or key holding a list of filters:
{
"$or": [{ "risk_level": { "$gte": 4 } }, { "tags": { "$containsAny": ["finance"] } }]
}
A filter on a field the list does not support is refused. Fields that
take sort read { column, direction }, where direction is ASC or DESC.
Page through a list
List fields return a connection: a data array holding one page, and pageInfo describing where the
page sits.
pageInfo field | Meaning |
|---|---|
hasNextPage | Whether more items follow this page. |
nextCursor | The cursor to send as after for the following page. |
hasPreviousPage | Whether items precede this page. |
previousCursor | The cursor to send as before for the preceding page. |
Ask for a page size with first. Without it, a page holds 50 items. first can be at most 500. A larger value is refused with Argument "first" must be at most 500. A few fields cap a page lower:
resourceAssignments and requestableCatalog return at most 100 items a page.
To read the next page, send the same operation with after set to the nextCursor you received, and
stop when hasNextPage is false. Treat a cursor as an opaque string: send back exactly what you
received, with the same filter and sort. Fields that also take last and before page backward the
same way. Send first or last, never both.
Count without paging
A connection has no total. The length of data is the size of one page, and a full page says nothing
about how many items exist. When you need a number, ask a field that counts:
query HighRiskResources($filter: JSONObject) {
resourceStats(filter: $filter, groupBy: ENABLED) {
total
groups {
key
count
}
}
}
Variables:
{ "filter": { "risk_level": { "$gte": 4 } } }
identityStats, resourceStats and accessRequestStats take the same filter as their lists and an
optional groupBy, and return the filtered total with a count for each group.
provisioningOperationsCount returns the number of provisioning operations that match a filter.
Explore in the browser
Opening https://<your Owlie domain>/api/graphql in a browser shows GraphiQL, an interactive editor
with the schema's documentation and autocomplete. It uses your dashboard session: if you aren't
signed in, Owlie sends you to sign in and then back. Operations you run there run as you, with your
roles, against live data.