# Authentication

The Postman v2 API uses [API keys](/postman-v2-admin-portal-for-api-users-mop/campaign-settings.md#api-keys) and static [IP whitelisting](/postman-v2-admin-portal-for-api-users-mop/campaign-settings.md#ip-address-whitelisting) to authenticate incoming requests from your server.

Your API keys carry many privileges, so be sure to keep them secure. Don't share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.

Authentication to the API is performed with [HTTP Bearer Auth](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#authentication_schemes).&#x20;

{% hint style="info" %}
You will first need to [Create Campaign](/postman-v2-general-user-guide-mop/create-campaign.md) on the admin portal before you can generate your `campaignId`
{% endhint %}

{% code title="An example curl request:" overflow="wrap" %}

```sh
curl https://<POSTMAN_V2_API_BASE_URL>/api/v2/campaigns/:campaignId/messages -H "Authorization: Bearer YOUR_API_KEY"
```

{% endcode %}

You must make all API calls over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Calls that you make over plain HTTP will fail. API requests without authentication will also fail.

If you make a request without authentication, you will receive HTTP 401 and the following in your response body:

```json
{
    "message": "Unauthorized",
    "statusCode": 401
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://postman-v2.guides.gov.sg/general-notes-for-api-users/authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
