Create a new external user of your Embedded application.
To exclude users from billing you can mark them as test users (see our Billing page for more info).
Required Token | Notes |
---|---|
Master | Obtained from the Tray app UI. Refer this. |
The mutation accepts the following as inputs:
Input | Required | Note |
---|---|---|
name | Yes | |
externalUserId | Yes | can be used to link the End User to an ID you already have for them in your external database. It's important to be able to access key info, such as contact email, you may have stored in your external system. Example: dealing with Expired Auths |
isTestUser | No | Boolean value that defaults to true (billable user) if you don't pass it. A test user allows you to create Solution Instances and run test data for a user without incurring any charges. This is useful for end to end testing. Please read our billing page here. |
clientMutationId | No | Only relevant if using the Relay GraphQL client |
Here is an example mutation:
mutation { createExternalUser(input: { name: "Dwight Schrute", externalUserId: "my-apps-user-id-for-dwight" }) { userId } }
mutation { createExternalUser(input: { name: "Dwight Schrute", externalUserId: "my-apps-user-id-for-dwight", clientMutationId: "some-mutation-id" #OPTIONAL - only needed for legacy Relay & Apollo clients }) { userId clientMutationId #OPTIONAL } }
It can return the following data:
Returned Data | Notes |
---|---|
userId | Tray Id of the user |
clientMutationId | Only relevant if using the Relay GraphQL client |
OK - Returns the userId of the newly created user
Unauthorized
Forbidden
Internal Error
curl -i -X POST \ https://tray.io/graphql \ -H 'Authorization: Bearer <MASTER_TOKEN>' \ -H 'Content-Type: application/json' \ -d '{ "query": "mutation($name: String!, $externalUserId: String!) {\n createExternalUser(input: { \n name: $name, \n externalUserId: $externalUserId \n }) {\n userId\n }\n}", "variables": { "name": "Dwight Schrute", "externalUserId": "my-apps-user-id-for-dwight" } }'
{- "data": {
- "createExternalUser": {
- "userId": "d235e0b1-XXXX-XXXX-XXXX-7d165cdf4171"
}
}
}
Create an accessToken for a given userId
A user token allows access to the APIs which require a user token (Create Solution Instance, Get Solution Instances, Create User Auth etc.) and should be passed as a Bearer in the Authorization header when calling those APIs.
Note: This access token expires after 2 days
Required Token | Notes |
---|---|
Master | Obtained from the Tray app UI. Refer this. |
The mutation accepts the following as inputs:
Input | Required | Notes |
---|---|---|
userId | Yes | obtained when creating a user (Mutations/Users/Create New User) or getting users (Queries/Users/Get Users) |
clientMutationId | No | Only relevant if using the Relay GraphQL client |
Here is an example mutation:
mutation { authorize(input: { userId: "d869ec65-XXXX-XXXX-XXXX-ac5c1a3958b6" }) { accessToken } }
mutation { authorize(input: { userId: "d869ec65-XXXX-XXXX-XXXX-ac5c1a3958b6", clientMutationId: "my-mutation-id" #OPTIONAL - only needed for legacy Relay & Apollo clients }) { accessToken clientMutationId #OPTIONAL } }
It can return the following data:
Returned Data | Notes |
---|---|
accessToken | a persistent token (valid for 2 days) that should be securely stored in your application. Allows access to the APIs which require a user token (e.g. createSolutionInstance) |
clientMutationId | Only relevant if using the Relay GraphQL client |
OK - Returns the accessToken of the user
Unauthorized
Forbidden
Internal Error
curl -i -X POST \ https://tray.io/graphql \ -H 'Authorization: Bearer <MASTER_TOKEN>' \ -H 'Content-Type: application/json' \ -d '{ "query": "mutation ($userId: ID!) {\n authorize(input: {\n userId: $userId\n }) {\n accessToken\n }\n}", "variables": { "userId": "d869ec65-XXXX-XXXX-XXXX-ac5c1a3958b6" } }'
{- "data": {
- "authorize": {
- "accessToken": "3346c4c957b74ca2a803dacf1485816d3fedde3a54b547b997cd64b72375a9d4"
}
}
}
Creates an authorization code that is used to configure config wizard URL or auth-only dialog URL. Refer this page on how it's used.
Note: This is a one-time use code which expires after 5 minutes
Required Token | Notes |
---|---|
Master | Obtained from the Tray app UI. Refer this. |
The mutation accepts the following as inputs:
Input | Required | Notes |
---|---|---|
userId | Yes | obtained when creating a user (Mutations/Users/Create New User) or getting users (Queries/Users/Get Users) |
clientMutationId | No | Only relevant if using the Relay GraphQL client |
Here is an example mutation:
mutation { generateAuthorizationCode( input: { userId: "d869ec65-XXXX-XXXX-XXXX-ac5c1a3958b6" }) { authorizationCode } }
mutation { generateAuthorizationCode( input: { userId: "d869ec65-XXXX-XXXX-XXXX-ac5c1a3958b6", clientMutationId: "my-mutation-id" #OPTIONAL - only needed for legacy Relay & Apollo clients }) { authorizationCode clientMutationId #OPTIONAL } }
It can return the following data:
Returned Data | Notes |
---|---|
authorizationCode | this is required to activate the Configuration Wizard |
clientMutationId | Only relevant if using the Relay GraphQL client |
OK - Returns the one time use authorizationCode for the user
Unauthorized
Forbidden
Internal Error
curl -i -X POST \ https://tray.io/graphql \ -H 'Authorization: Bearer <MASTER_TOKEN>' \ -H 'Content-Type: application/json' \ -d '{ "query": "mutation ($userId: ID!) {\n generateAuthorizationCode( input: {\n userId: $userId\n }) {\n authorizationCode\n }\n}", "variables": { "userId": "d869ec65-XXXX-XXXX-XXXX-ac5c1a3958b6" } }'
{- "data": {
- "generateAuthorizationCode": {
- "authorizationCode": "a61eb70884f9af554a941876a66560b4bbfe48cc"
}
}
}
Can be used to mark a user as a test user allowing you to create Solution Instances and run test data for a user without incurring any charges (see our Billing page for more info)
Required Token | Notes |
---|---|
Master | Obtained from the Tray app UI. Refer this. |
The mutation accepts the following as inputs:
Input | Required | Note |
---|---|---|
id | Yes | |
isTestUser | Yes | Booelan value. A test user allows you to create Solution Instances and run test data for a user without incurring any charges |
Here is an example mutation:
mutation { updateExternalUser(input: { userId: "53824943-XXXX-XXXX-XXXX-088aee14038e", isTestUser: true }) { user{ name id externalUserId isTestUser } } }
mutation { updateExternalUser(input: { userId: "53824943-XXXX-XXXX-XXXX-088aee14038e", isTestUser: "true", clientMutationId: "some-mutation-id" #OPTIONAL - only needed for legacy Relay & Apollo clients }) { user{ name id externalUserId isTestUser clientMutationId #OPTIONAL } } }
It can return the following data:
Returned Data | Notes |
---|---|
name | |
id | |
externalUserId | |
isTestUser |
OK - Updates the user with the new data provided
Unauthorized
Forbidden
Internal Error
curl -i -X POST \ https://tray.io/graphql \ -H 'Authorization: Bearer <MASTER_TOKEN>' \ -H 'Content-Type: application/json' \ -d '{ "query": "mutation ($userId: ID!, $isTestUser: Boolean ){\n updateExternalUser(input: {\n userId: $userId,\n isTestUser: $isTestUser\n }) {\n user{\n\t\t\tname\n\t\t\tid\n\t\t\texternalUserId\n\t\t\tisTestUser\n\t\t}\n }\n}", "variables": { "userId": "53824943-XXXX-XXXX-XXXX-088aee14038e", "isTestUser": true } }'
{- "data": {
- "updateExternalUser": {
- "user": {
- "name": "Dwaight Schrute",
- "id": "ad15b7ae-4c2d-4574-bf4f-5e8e1097a6e9",
- "externalUserId": "test003",
- "isTestUser": true
}
}
}
}
This mutation is used to delete a user from your Embedded application.
Note: Deleting a user will also disable and delete all Solution Instances associated with that user.
Required Token | Notes |
---|---|
Master | Obtained from the Tray app UI. Refer this. |
The mutation accepts the following as inputs:
Input | Required | Notes |
---|---|---|
userId | Yes | obtained with Queries/Users/Get Users |
clientMutationId | No | Only relevant if using the Relay GraphQL client |
Here is an example mutation:
mutation { removeExternalUser(input: { userId: "53824943-XXXX-XXXX-XXXX-088aee14038e" }) { clientMutationId # REQUIRED - must specify as return field, not required to provide this in mutation function } }
mutation { removeExternalUser(input: { userId: "53824943-XXXX-XXXX-XXXX-088aee14038e", clientMutationId: "someClientMutationId" }) { clientMutationId # REQUIRED - must specify as return field } }
It can return the following data:
Returned Data | Notes |
---|---|
clientMutationId | while this data is only relevant if using the Relay GraphQL client, it is actually required here as currently this mutation does not return any other data |
OK - Deletes the end user
Unauthorized
Forbidden
Internal Error
curl -i -X POST \ https://tray.io/graphql \ -H 'Authorization: Bearer <MASTER_TOKEN>' \ -H 'Content-Type: application/json' \ -d '{ "query": "mutation {\n removeExternalUser(input: {userId: $userId}) {\n clientMutationId # REQUIRED - must specify as return field, not required to provide this in mutation function\n }\n}", "variables": { "userId": "53824943-XXXX-XXXX-XXXX-088aee14038e" } }'
{- "data": {
- "removeExternalUser": {
- "clientMutationId": null
}
}
}