Pages

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from this space and version 5.1

...

All requests to the Graniitti API must be authenticated with an access token. You get your personal access token through your Frosmo user account, so you need to first set up the account. For more information, see Getting started with the Frosmo Platform Creating visitor journeys.

Getting your personal access token

...

  1. In the Frosmo Control Panel, select Utilities > Frosmo APIs.
  2. In the Graniitti API

    .

    Click section, click Create token.

    Getting your personal access token

  3. Copy the token. It will not be shown on the page again.

    Getting your personal access token

You now have your personal access token for authenticating with the Graniitti API. For more information about the token, see Authentication.

Warning

Do not make Graniitti API requests in client-side code that is accessible to parties you do not trust, as this will expose your token to them. Use the Graniitti API only in server-side code and in client-side code that is only accessible to parties you trust.

Getting the base URL for requests

...

To get the base URL for the latest version in your platform instance:

  1. In the Frosmo Control Panel, select Utilities > Frosmo APIs.
  2. In the Graniitti API

    .

    Copy section, copy the base URL shown on the page.

    Getting the base URL for requests

You now have the base URL for sending requests to the Graniitti API.

...

Now that you have your personal access token, test that it works correctly by making the following calls to the Graniitti API.

Info

This guide uses cURL examples to illustrate API calls, so you can simply copy and paste the relevant code to your application, or you can run the cURL commands directly from the command line (provided you have cURL installed).

To test your access:

  1. Retrieve your own user information by sending a GET request to /users with your first name and last name as query parameters. Add your token to the request using the Authorization header, and prefix the token with "Bearer" followed by a space.

    Code Block
    languagepowershell
    themeRDark
    curl -X GET \
    --header 'Authorization: Bearer <access_token>' \
    'https://<graniitti_api_domain>/v0/users?firstname=<your_first_name>&lastname=<your_last_name>'


    Info

    The domain name in the above URL depends on your Frosmo Platform instance. To find out which domain name you need to use, see Getting the base URL for requests.


  2. Create a new user by sending a POST request to /users with the user information passed as a JSON object.

    Code Block
    languagepowershell
    themeRDark
    curl -X POST \
    --header 'Authorization: Bearer <access_token>' \
    --header 'Content-Type: application/json' \
    -d '{"firstname":"User","lastname":"User","email":"user.user@company.com","password":"8sKJ0688p!"}' \
    'https://<graniitti_api_domain>/v0/users'

    Note the user ID in the response body.

  3. Retrieve the user you just created by sending a GET request to /users/<user_id>. Use the user ID from the response to the POST request.

    Code Block
    languagepowershell
    themeRDark
    curl -X GET \
    --header 'Authorization: Bearer <access_token>' \
    'https://<graniitti_api_domain>/v0/users/<user_id>'


  4. Delete the user by sending a DELETE request to /users/<user_id>. Use the user ID from the response to the POST request.

    Code Block
    languagepowershell
    themeRDark
    curl -X DELETE \
    --header 'Authorization: Bearer <access_token>' \
    'https://<graniitti_api_domain>/v0/users/<user_id>'


...