For the complete documentation index, see llms.txt. This page is also available as Markdown.

Retrieve user data using GraphQL API

A walkthrough: get everything the platform holds about one user, by any identifier.

Your goal

Retrieve the data held about one user, starting from whatever identifier you have - for an access request, a support investigation, or a real-time personalisation call.

Expected outcome

A single response containing the fields you need, and an understanding of what the response does not include.

Prerequisites

  • An authenticated call. For code running in a browser or an app, use signature authentication, not a long-term token.

  • One identifier for the user.

  • Fields present in your schema - the GraphQL schema is derived from yours.

Walk through it

1

Start from the identifier you have

Each identifier type has its own selector function:

You have
Function

A UserPoint ID

user_point(user_point_id: "...")

An email hash

user_point_by_email_hash(email_hash: "...")

An account ID and a compartment ID

user_point_by_user_account_id(compartment_id: "...", user_account_id: "...")

A user agent ID

user_point_by_user_agent_id(user_agent_id: "...")

2

Confirm the user exists

Start minimal, so a problem with the identifier is not confused with a problem in the field selection:

query MyQuery {
  user_point_by_email_hash(email_hash: "xxxxxxxxxxxxxxxxxxx") {
    id
    creation_ts
  }
}
3

Ask for what you need

query MyQuery {
  user_point(user_point_id: "xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx") {
    id
    creation_ts
    profiles {
      gender
      birth_date
    }
    accounts {
      compartment_id
      user_account_id
    }
    segments {
      id
    }
    scenarios {
      scenario_id
    }
  }
}

The field names here depend on your schema - gender and birth_date are examples. Check your own model, in the Query Tool or in the GraphQL playground available in Computing Console.

4

Send it

POST /v1/datamarts/:datamartId/query_executions/graphql

The body carries a query parameter with the query text, starting with query MyQuery {. Escape double quotes as needed. A 200 returns { "data": { ... } }.

5

Narrow the activities, knowing the caveat

@filter restricts the objects returned:

query micsQuery {
  user_point(user_point_id:"xxx") {
    activities {
      events @filter(clause: "name == \"$home_view\""){
        ts
      }
    }
  }
}

When GraphQL is the wrong tool

Situation
Use instead

You need the complete history of a user, beyond 100 activities

OTQL, or Explore a user profile to read the raw activities

You need data for many users

You need to write something

The GraphQL endpoint is read-only. See Server-side events

You are answering a formal access request

Exercise rights of the user, which also covers looking the person up by every identifier they gave you

Verify

  • The minimal query returns an id, confirming the identifier resolves.

  • Every field you request exists in your schema - an unknown field is a query error, not an empty value.

  • For anything depending on completeness, you have accounted for the 100-activity limit.

  • Calls stay within the endpoint's rate limit; 429 means you exceeded it.

Last updated

Was this helpful?