> For the complete documentation index, see [llms.txt](https://docs.txnhog.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.txnhog.co/usage/api-examples.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.txnhog.co/usage/api-examples.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
