# Authentication

{% hint style="warning" %}

* Your API key is sensitive and should be treated as a secret.
* Only requests from whitelisted IP addresses will be accepted.
* If your API key is compromised, delete it immediately through the web UI and generate a new one.
  {% endhint %}

Postman's APIs uses API key-based and static IP whitelisting for authentication. API keys are on a per-campaign basis and can only send and retrieve messages from the same campaign.

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;

Include your API key in the `Authorization` header:

```
Authorization: Bearer <YOUR_API_KEY>
```

{% tabs %}
{% tab title="Sample Request" %}
The following request sends a single message to a recipient.

```bash
curl -X POST https://postman.gov.sg/api/v2/campaigns/campaign_abc123/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer key_prod_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6" \
  -d '{
    "recipient": "6591112222",
    "language": "english"
  }'
```

{% endtab %}

{% tab title="Sample Response" %}
Message successfully created and queued for sending.

```json
{
  "id": "msg_abc123xyz789",
  "recipient": "6591112222",
  "language": "english",
  "latestStatus": "created",
  "campaignId": "campaign_abc123",
  "createdAt": "2024-01-15T10:30:00Z",
  "updatedAt": "2024-01-15T10:30:00Z"
}
```

{% endtab %}
{% endtabs %}

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/technical-users-api/api-reference/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.
