# IMessageQueue.send() method · @imqueue/core

Source: https://imqueue.org/api/core/latest/core.imessagequeue.send/
Published: 2026-08-04
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/core 3.3.2 — generated reference, not hand-written

Sends a message to the specified queue with the given data.

**Signature:**

```typescript
send(toQueue: string, message: JsonObject, delay?: number, errorHandler?: (err: Error) => void): Promise<string>;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| toQueue | string | name of the destination queue |
| message | [JsonObject](https://imqueue.org/api/core/latest/core.jsonobject/) | message data to send |
| delay | number | _(Optional)_ if specified, the message becomes available in the target queue only after this many milliseconds. This is a minimum, not a schedule: the message is released by the watcher, either on a Redis expired-key notification or on the next [IMQOptions.watcherCheckDelay](https://imqueue.org/api/core/latest/core.imqoptions.watchercheckdelay/) poll, so availability may lag by up to that interval. A delay of `0` or `undefined` sends immediately. |
| errorHandler | (err: Error) => void | _(Optional)_ callback invoked only when an internal error occurs during message send execution |


**Returns:**

Promise<string>

the identifier assigned to the message

## Exceptions

TypeError when the queue is in [IMQMode.WORKER](https://imqueue.org/api/core/latest/core.imqmode/)-only mode, or when a writer connection cannot be established

## Remarks

The returned promise resolves as soon as the write has been dispatched — before the queue host confirms it, and long before the message is consumed. The identifier is generated locally, so it is available even if the write later fails. A resolved promise is therefore not evidence that the message was enqueued: supply `errorHandler` to observe write failures, which never reject.

Starts the queue implicitly when it has not been started yet. Delivery is at-least-once, so handlers must be idempotent.

