Create a User API Key

  1. Go to the Admin Console and click Developer
  2. Click the New API key button
  3. Set the Description field to Getting Started
  4. Select User API from Type dropdown
  5. Select Read and write from the User scope dropdown
  6. Click the Create button
  7. Click Copy when the newly created key appears

Make an Unauthenticated Request

Use the key to make a request to the session endpoint.

curl https://api.userhub.com/user/v1/session?key=pk_43wEe2...

Which will return an unauthenticated view of the session:

{
  "user": null,
  "expireTime": null,
  "scopes": ["user.readwrite"]
}

Generate a User Token

Follow the instructions in the Admin API getting started guide and use those credentials to create an API session:

curl https://api.userhub.com/admin/v1/users/usr_26wWMKJR3fjzpN:createApiSession \
  -X POST -H 'Authorization: Bearer sk_2UHNcx...'

Which will return an access token:

{
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ0bnRfZmFJ...",
  "expireTime": "2023-02-01T23:24:25.26Z"
}

Make an Authenticated Request

Update the session request to include the user access token.

curl https://api.userhub.com/user/v1/session?key=pk_43wEe2... \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ...'

Which will return an authenticated view of the session:

{
  "user": {
    "id": "usr_26wWMKJR3fjzpN",
    "displayName": "Jane Doe"
  },
  "expireTime": "2023-02-01T23:24:25.26Z",
  "scopes": ["user.readwrite"]
}

Most endpoints in the User API require that you provide a user access token, but some can be called with only the User API key.

PreviousAdmin API Key
NextConnections

Turn users intorevenue
$

Subscribe to monthly product updates

© 2024 UserHub

Integrations

    UserHub & Auth0UserHub & Stripe BillingUserHub & Google CloudUserHub & FirebaseUserHub & Custom Auth

Resources