# API Example

## Send a transactional message

<mark style="color:green;">`POST`</mark> `https://txnhog.co/txn/api/your_message_key`

API POST Example for sending a transactional message. This is a simple example of sending a name, email, and phone number to the transactional template. The API accepts only string values, as application/json or application/x-www-form-urlencoded.\
\
When using an email template, the parameter "email" is required, and when using an sms template, the parameter "phone" is required.

#### Request Body

| Name   | Type   | Description                                                                                                               |
| ------ | ------ | ------------------------------------------------------------------------------------------------------------------------- |
| apiKey | string | Your API key, listed below each of your transactional messages. This key is private, and should only be used server-side. |
| name   | string | Name of the person receiving the transactional message. Exposed in your template with the {{name}} tag                    |
| email  | string | Exposed in your template with the {{email}} tag. Required if sending an email.                                            |
| phone  | string | Exposed in your template with the {{phone}} tag. Required if sending an sms.                                              |

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```
{    "name": "Cake's name",    "recipe": "Cake's recipe name",    "cake": "Binary cake"}
```

{% endtab %}

{% tab title="404 Could not find a cake matching this query." %}

```
{    "message": "Ain't no cake like that."}
```

{% endtab %}
{% endtabs %}

You can POST any key/value pair of up to 1400 characters each. This allows for variables to insert password reset links, image urls, just about anything. Note that HTML will be sanitized and encoded.


---

# 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://docs.txnhog.co/usage/api-examples.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.
