# HTTP Gateway

A first-class RESTful HTTP interface for NATS.

note

The KV Store API is currently available in **preview** to all users.

## Connecting

The HTTP Gateway is exposed via a standard endpoint over HTTPS `https://api.ngs.global`. Refer to the interactive [OpenAPI Spec](https://api.ngs.global/api/) for details on the available endpoints and methods.

An API token is required to connect and is scoped to a User within an Account. Credentials cannot be used directly. The token can be obtained through the user interface or through the Synadia Cloud API.

### API token through user interface

To obtain a token through the user interface:

* Go to the User page and click the **Get Connected**
* Select the **HTTP Gateway** dialog
* Click **Generate Token**

![](/assets/images/get_connected-debf113c2f17ae6cd16326f1b912dc5a.png) ![](/assets/images/generate_token-1f4b8ef4b429b09293d969d8fc30b1e4.png)

### API token through Synadia Cloud API

To obtain an HTTP Gateway token through the Synadia Cloud API, you can use the [OpenAPI interface](https://cloud.synadia.com/api-docs#post-/nats-users/-userId-/http-gw-token) or use an HTTP client to make the request.

```
curl -X POST -H "Accept: application/json" \

    "https://cloud.synadia.com/api/core/beta/nats-users/{userId}/http-gw-token"
```

Where `{userId}` is the ID of the User you want to generate the token for.

### First steps

The token will look something like this:

```
nhg_2DDZKG2rmX7HBhETu_2ZapvJoSwwrs9JibstLG6d7cUW1p6RYSXF68hCTLqgFX
```

You can confirm it works by trying it out with any standard HTTP client such as `curl`:

```
curl -H "Authorization: Bearer <API_TOKEN>" \

    https://api.ngs.global/v1/kvm/buckets
```

If there are existing KV buckets in your account, you will see them listed, otherwise the response will be an empty array.

## More examples

For more examples see the [HTTP Gateway preview announcement](https://www.synadia.com/blog/synadia-cloud-http-gateway-preview).

## Token management

It is recommended to create dedicated Users for applications that will be using the HTTP Gateway, separate from the NATS-centric applications. A User provides the ability to set permissions and expiry as well as rotate and revoke the associated credentials.

## API reference

Refer to the full [OpenAPI Reference](https://api.ngs.global/api/) for more details on the available endpoints and methods.
