> For the complete documentation index, see [llms.txt](https://bittu-1.gitbook.io/meshkit-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bittu-1.gitbook.io/meshkit-documentation/api/send.md).

# send()

## Overview

Stores a simple message object for a recipient. Internally, `send()` creates a `MeshkitMessage` and calls `store()`.

## Purpose

Use `send()` when you want MeshKit to wrap a string payload in the standard `MeshkitMessage` model and store it on IPFS.

## Endpoint / Method

```ts
async send(
  recipientId: string,
  message: string
): Promise<MeshkitRecord<MeshkitMessage>>
```

Provider endpoint:

```http
POST https://api.pinata.cloud/pinning/pinJSONToIPFS
```

## Parameters

| Name          | Type     | Required | Description                               |
| ------------- | -------- | -------- | ----------------------------------------- |
| `recipientId` | `string` | Yes      | Application-defined recipient identifier. |
| `message`     | `string` | Yes      | Message payload to store.                 |

### Request schema table

| Field         | Type     | Required | Notes                                   |
| ------------- | -------- | -------- | --------------------------------------- |
| `recipientId` | `string` | Yes      | Copied to `MeshkitMessage.recipientId`. |
| `message`     | `string` | Yes      | Copied to `MeshkitMessage.payload`.     |

## Response

Returns `Promise<MeshkitRecord<MeshkitMessage>>`.

```ts
interface MeshkitMessage {
  recipientId: string;
  payload: string;
  timestamp: number;
}
```

The returned `data` field contains the message object.

### Response schema table

| Field       | Type             | Description                                         |
| ----------- | ---------------- | --------------------------------------------------- |
| `cid`       | `string`         | CID returned by the internal `store(payload)` call. |
| `timestamp` | `number`         | Record timestamp from `store()`.                    |
| `data`      | `MeshkitMessage` | Message object stored on IPFS.                      |
| `size`      | `number`         | `JSON.stringify(payload).length`.                   |

## Examples

### Example request

```ts
const record = await meshkit.send(
  "user_123",
  "Invoice INV-1001 is available."
);
```

### Example response

```ts
{
  cid: "bafybeimessageexamplecid",
  timestamp: 1760000000000,
  data: {
    recipientId: "user_123",
    payload: "Invoice INV-1001 is available.",
    timestamp: 1760000000000,
  },
  size: 91,
}
```

## Errors

| Error                  | Cause                                    |
| ---------------------- | ---------------------------------------- |
| Provider error details | Pinata rejected the JSON pin request.    |
| `HTTP error 401`       | Invalid Pinata JWT.                      |
| Serialization error    | Message object could not be stringified. |

### Error schema table

| Field     | Type     | Description                                                                  |
| --------- | -------- | ---------------------------------------------------------------------------- |
| `name`    | `string` | Standard JavaScript error name.                                              |
| `message` | `string` | Pinata error details, `HTTP error {status}`, or serialization error message. |

## Notes

* `send()` does not deliver a push notification, email, websocket event, or inbox update.
* `recipientId` is stored as plain JSON.
* The current implementation does not encrypt messages.

## Best Practices

* Treat this as message storage, not message delivery.
* Do not store private messages unless they are encrypted before calling `send()`.
* Persist the returned CID so the recipient or application can later call `receive()`.

## Related APIs

* [receive()](/meshkit-documentation/api/receive.md)
* [store()](/meshkit-documentation/api/store.md)


---

# 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://bittu-1.gitbook.io/meshkit-documentation/api/send.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.
