> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/troubleshooting-and-resources/armory/general/accessing-the-spinnaker-rest-api-using-httpie-and-jq.md).

# Accessing the Spinnaker REST API using HTTPie and jq

### Introduction <a href="#introduction" id="introduction"></a>

This article advises about how to use `HTTPie` to access the `Spinnaker REST API`. It provides guidelines about using the Spinnaker API programmatically.

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

The `Spinnaker REST API` can be accessed using `HTTPie`. The results can be filtered and formatted by `jq`.The following are the prerequisites for accessing the Spinnaker API in this KB:

* The Spinnaker API (Gate) URL.\* Download and install of HTTPie: <https://httpie.io/> and jq: <https://stedolan.github.io/jq/download/> \*\*Note: \*\*For long term use, consider the use of `x509 certificates` for Spinnaker to make the calls. For development cases, a session cookie after logging in to Spinnaker can be used to test the `REST API` call. In the examples below, a session cookie will be used.

### Instructions <a href="#instructions" id="instructions"></a>

### Attain a session cookie <a href="#attain-a-session-cookie" id="attain-a-session-cookie"></a>

* Log on to the `Deck GUI`.
* Open the **Developer Tools** of your browser.
* Go to the **Network** tab -> find the call to **user** on the left tab.
* Look for the **Request Headers** and the **cookie** parameter. This cookie will need to be set when making API calls.
* Note that this cookie does expire after some time and is not permanent.

### Using the Spinnaker REST API <a href="#using-the-spinnaker-rest-api" id="using-the-spinnaker-rest-api"></a>

In the following examples we have set the parameters as follows: **Gate URL** GATE=<http://x.x.x.x>

## Spinnaker Gate Session Cookie, below is just an example. <a href="#spinnaker-gate-session-cookie-below-is-just-an-example" id="spinnaker-gate-session-cookie-below-is-just-an-example"></a>

SPINCOOK='Cookie:SESSION=YjdhNDg3NmQtZjE5Zi00xxxxxxxxxx'

## Spinnaker pipeline ID, below is just an example. <a href="#spinnaker-pipeline-id-below-is-just-an-example" id="spinnaker-pipeline-id-below-is-just-an-example"></a>

PIPEID='01EWXEEZTZPX09FE86XA7S75BA'

## Spinnaker Application Name <a href="#spinnaker-application-name" id="spinnaker-application-name"></a>

APP=spintest

## Create httpie session named test. Then use the session name for all the following calls. <a href="#create-httpie-session-named-test-then-use-the-session-name-for-all-the-following-calls" id="create-httpie-session-named-test-then-use-the-session-name-for-all-the-following-calls"></a>

## Setting verify to no will skip host SSL certificate verification. <a href="#setting-verify-to-no-will-skip-host-ssl-certificate-verification" id="setting-verify-to-no-will-skip-host-ssl-certificate-verification"></a>

## This setting should only be used if GATE is using a self-signed certificate. <a href="#this-setting-should-only-be-used-if-gate-is-using-a-self-signed-certificate" id="this-setting-should-only-be-used-if-gate-is-using-a-self-signed-certificate"></a>

## This will eliminate having to pass the cookie which gets tricky <a href="#this-will-eliminate-having-to-pass-the-cookie-which-gets-tricky" id="this-will-eliminate-having-to-pass-the-cookie-which-gets-tricky"></a>

eval http --verify=no --session=test $GATE/applications "'"$SPINCOOK"'"

## create/update applications and projects (see example below for min-app-create.json) <a href="#createupdate-applications-and-projects-see-example-below-for-min-app-createjson" id="createupdate-applications-and-projects-see-example-below-for-min-app-createjson"></a>

eval http --verify=no --session=test POST $GATE/tasks

The following is an example of `min-app-create.json` file which will create an application `app1` with minimal configuration and can be used as a test.

```
 {
   "job": [
       {
           "type": "createApplication",
           "application": {
               "cloudProviders": "kubernetes",
               "instancePort": 80,
               "providerSettings": {
                   "aws": {
                       "useAmiBlockDeviceMappings": false
                   }
               },
               "name": "app1",
               "email": "app@example.com",
               "permissions": {
                   "READ": [
                       "superadmins",
                       "qa"
                   ],
                   "EXECUTE": [
                       "superadmins"
                   ],
                   "WRITE": [
                       "superadmins"
                   ]
               }
           },
           "user": "test_user"
       }
   ],
   "application": "app1",
   "description": "Create Application: app1"
}
```

For more information on the Spinnaker API please refer to: <https://spinnaker.io/reference/api> and <https://docs.armory.io/docs/spinnaker-user-guides/writing-scripts/>.
