Your submission was sent successfully! Close

You have successfully unsubscribed! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates about Ubuntu and upcoming events where you can meet our team.Close

How to make a REST API request

This is only available for self-hosted Landscape accounts at this time.

This guide demonstrates how to make a request using the Landscape REST API from a self-hosted Landscape account. The general steps and an example using curl are provided.

Make a REST API request with your preferred API tool

The general steps to make a REST API request are:

  1. Provide your login credentials with POST
  2. Copy your token from the output
  3. Assign your token to a new variable, such as JWT
  4. Make your API request, using your token for authorisation

Make a REST API request with curl

To make a REST API request with curl:

  1. Provide your login credentials with POST. Your request will be similar to the following

    curl -X POST "https://your-landscape.domain.com/api/v2/login" -d '{"email": "jane@example.com", "password": "jane-pwd", "account": "standalone"}'
    

    And you’ll receive output similar to:

    {
        "accounts": [
            {
                "default": true,
                "name": "standalone",
                "title": "Jane-Organisation"
            }
        ],
        "current_account": "standalone",
        "email": "jane@example.com",
        "name": "Jane Smith",
        "token": "qkJ0eXAiOiJKV1QiLCJhbGciOiJskdi296MTcxMDM2MTQxNiwic3ViIjoieWFuaXNhLnNjaGVyYmVyQGNhbm9uaWNhbC5jb20iLCJhY2MiOiJzdGFuZGFsb2i93nboPRfXp50"
    }
    
  2. Copy your token from the output and assign it to a new variable, such as JWT:

    JWT="qkJ0eXAiOiJKV1QiLCJhbGciOiJskdi296MTcxMDM2MTQxNiwic3ViIjoieWFuaXNhLnNjaGVyYmVyQGNhbm9uaWNhbC5jb20iLCJhY2MiOiJzdGFuZGFsb2i93nboPRfXp50"
    
  3. Make your API request, using your token as authorisation. For example:

    curl -X GET https://your-landscape.domain.com/api/v2/activities -H "Authorization: Bearer $JWT"
    

This page was last modified 4 days ago. Help improve this document in the forum.