Kindly read the Authentication page to know about the host url, token generation, token permissions and scopes before moving to further sections.

Let’s walk through some sample requests to get familiar with the general usage of the developer-ready endpoints!

For the sake of the example, we shall demonstrate the usage of the /createcollection developer-ready endpoint. To find out more about a specific endpoint’s fields and usage, please refer to its API reference page!

Using a User-Scoped Token

1

Ensuring accurate token information

  • The permissions for the token should be set to USER, the user email should be set to a valid user email (say, john.doe@yourdomain.com) while creating the token.
  • The scope list for the token should contain the COLLECTIONS scope.
2

Making the request

Use the following cURL command to create a collection.

curl -X POST https://customer-be.glean.com/rest/api/v1/createcollection \
-H 'Authorization: Bearer <token>' \
-d '{
     "name": "Sample Collection - '$(date +"%Y-%m-%d %H:%M:%S")'",
     "description": "A brief summary of the collection\'s contents."
}'

If you get a response with a status code other that 200, use the error response to figure out what might have gone wrong. For example, the token may have expired, causing the request to fail.

3

Verifying the collection

Go to the Collections tab to verify that your collection has been created! Don’t forget to delete the test collection once you’re done!

As seen in the screenshot below, the email provided was identical to that of the user-logged in. If that is not the case, the Created By field will reflect the appropriate creator, based on the inferred email.

Using a Global Token

1

Ensuring accurate token information

  • The permissions for the token should be set to GLOBAL
  • The user email would not be set.
  • The scope list for the token should contain the COLLECTIONS scope.
2

Making the request

  • Use the following cURL command to create a collection
  • Replace <User email> in the X-Scio-Actas header with a valid email address of a user on whose behalf the request is intended to be made.
cURL
curl -X POST https://customer-be.glean.com/rest/api/v1/createcollection \
-H 'Authorization: Bearer <token>' \
-H 'X-Scio-Actas: <User email>' \
-d '{
     "name": "Sample Collection - '$(date +"%Y-%m-%d %H:%M:%S")'",
     "description": "A brief summary of the collection\'s contents."
}'

If you get a response with a status code other that 200, use the error response to figure out what might have gone wrong. For example, the token may have expired, causing the request to fail.

If the X-Scio-Actas header is not specified or blank, the request will fail with a 400: Required header missing: X-Scio-ActAs error.

If the X-Scio-Actas header is specified with an invalid email, the request will fail with a 401: Invalid identity error.

3

Verifying the collection

  • Go to the Collections tab to verify that your collection has been created! Don’t forget to delete the test collection once you’re done!

As seen in the screenshot below, the email provided was identical to that of the user-logged in. If that is not the case, the Created By field will reflect the appropriate creator, based on the inferred email.

Was this page helpful?