Using curl

While Swagger UI provides a visual interface into the API, it is often desirable to send API calls via the command line. For this, curl can be used.

Required information

To send a curl request to the API, two things are required:

  • An API key

  • The curl command string

Obtaining an API key

If an API key is not already available from previous API usage, the following steps should be followed.

  1. Log into the planet console using a Reblaze account (i.e., not using SSO). The account must have an Access Level of Editor or higher.

  2. Navigate to Account by selecting the user icon on the top right of the page

  3. Navigate to Account Details -> API Keys. (If Account Details is not displayed in the Account menu, verify that the login was done directly into the planet using a Reblaze account. If SSO is used, Account Details will not be available in the interface.)

  4. Select "New" -> Enter key name -> "Confirm"

  5. Copy the value of that key for use within curl.

Constructing the curl command string

Sending an API request via Swagger UI will also construct and display its curl command string:

  1. Expand the desired namespace, and then the desired route within the namespace.

  2. Select the "Try it Now" button

  3. Edit the input fields (if any), providing all required inputs

  4. Select the "Execute" button

  5. After sending the request, Swagger UI will display the curl command string. Copy this.

  6. To send this request using curl, edit the command string to include an additional header for the API key obtained earlier.

Example

When Swagger UI is used to get a list of configurations via GET /api/v4/conf/configs, it will also display this curl command:

curl -X 'GET' \
  'https://www.mysite.com/api/v4/conf/configs' \
  -H 'accept: application/json'

To submit this command directly via curl, the following header must be added:

-H "Authorization:Basic <api-key-obtained-earlier>"

...without the <>, and where api-key-obtained-earlier is the string obtained above.

Last updated