Pages

To get started with the Graniitti API:

  1. Set up your Frosmo user account.
  2. Get your personal access token for authenticating with the Graniitti API.
  3. Get the base URL for Graniitti API requests.
  4. Test your access to the Frosmo back end.

Setting up your Frosmo user account

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 Creating visitor journeys.

Getting your personal access token

To get your personal access token:

  1. In the Frosmo Control Panel, select Utilities > Frosmo APIs.
  2. In the Graniitti API 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.

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

The base URL for Graniitti API requests depends on your Frosmo Platform instance and the API version you're using.

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 section, copy the base URL.

    Getting the base URL for requests

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

Testing your access

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

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.

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

    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.

    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.

    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.

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

Now that you have a working token, learn about the basics of the Graniitti API and its RESTful features.

  • No labels