# Message methods: create, get, list

URL: /code/sdk/message/records · Id: `page:code/sdk/message/records`

> The Message Verbs create, get, list as typed SDK methods, with inputs, result, refusals and an example.

Reference for [Message](/business/nouns/message), one group of [Message methods](/code/sdk/message).

### Message.create
Creates a Message. [Verb page](/business/nouns/message/create?interface=sdk).

```ts
interface MessageVerbs {
  create(input: MessageCreateInput, options?: SB.CallOptions): SB.Call<Message>
}
```

Emits `Message.created`.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `medium` | `string` | Yes | One of `email`, `sms`, `voice`, or `chat`. |
| `direction` | `string` | Yes | One of `inbound` or `outbound`. |
| `body` | `text` | Yes | What it says. |
| `from` | `string` | No | The sender: an address, a number, or a Channel id. |
| `to` | `string` | No | The recipient: an address, a number, or a Person id. |
| `subject` | `string` | No | The subject line, for email. |
| `purpose` | `string` | No | Why it goes out, such as onboarding; consent and suppression rules read it. |
| `sequence` | [Sequence](/business/nouns/sequence) | No | A Sequence sends Messages, each at its own step and wait. |
| `channel` | [Channel](/business/nouns/channel) | No | Every Message flows through one Channel. |
| `thread` | [Thread](/business/nouns/thread) | No | A Thread groups Messages that reply to one another. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `message` | [Message](/business/nouns/message) | Yes | The Message. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```ts
import { $ } from 'startup-builder'

const message = await $.Message.create({ medium: 'email', direction: 'inbound', body: 'Example body' })
```

### Message.get
Returns one Message by id. [Verb page](/business/nouns/message/get?interface=sdk).

```ts
interface MessageVerbs {
  get(input: MessageGetInput, options?: SB.CallOptions): SB.Call<Message>
}
```

Reads only: it emits no Event.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Message. |
| `at` | `string` | No | A time or Version name: the record as it stood then. Unset: as it stands now. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `message` | [Message](/business/nouns/message) | Yes | The Message. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```ts
import { $ } from 'startup-builder'

const message = await $.Message.get({ id: 'message_3Dg8ysSOyQ' })
```

### Message.list
Returns Messages, newest first, one page at a time. [Verb page](/business/nouns/message/list?interface=sdk).

```ts
interface MessageVerbs {
  list(input?: MessageListInput, options?: SB.CallOptions): SB.ListCall<Message>
}
```

Reads only: it emits no Event.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | `integer` | No | At most this many records, up to 100. The default is 20. |
| `after` | `string` | No | The cursor from the previous page. |
| `where` | `string` | No | A filter over the properties, such as `paidAt = null and total.amount > 500`. |
| `sort` | `string` | No | Properties to sort by, comma-separated; a leading minus sorts descending. |
| `total` | `boolean` | No | True adds the match count as `meta.total`, exact up to 10,000 matches and estimated above. |
| `facets` | `string` | No | Properties to count by value, comma-separated, returned as `meta.facets`. |
| `fields` | `string` | No | Properties to return on each record, comma-separated; `$id` and `$type` always return. |
| `include` | `string` | No | Related records to embed in place of their URLs, comma-separated. |
| `depth` | `integer` | No | How many levels of related records to embed. The default is 1. |
| `q` | `string` | No | Words to match across the text properties, ranked by relevance. |
| `match` | `string` | No | Ranks the search by `words`, or `meaning`; words is the default. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `messages` | list of [Message](/business/nouns/message) | Yes | One page of Messages. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```ts
import { $ } from 'startup-builder'

const messages = await $.Message.list({ limit: 20 })
```