# social.colibri.beta.bridge.importMessages

> Published by [colibri.social](https://lexicon.garden/identity/did:plc:mprdjqjluoswa7awzggaggj3)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:mprdjqjluoswa7awzggaggj3/social.colibri.beta.bridge.importMessages)
- [Documentation](https://lexicon.garden/lexicon/did:plc:mprdjqjluoswa7awzggaggj3/social.colibri.beta.bridge.importMessages/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:mprdjqjluoswa7awzggaggj3/social.colibri.beta.bridge.importMessages/examples)

## Definitions

### `social.colibri.beta.bridge.importMessages#importResult`

**Type**: `object`

Where an imported message was written.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `remoteMessage` | `string` | Yes | The message's id on the other service. |
| `rkey` | `string` (record-key) | Yes | Record key of the record the community wrote. |

### `social.colibri.beta.bridge.importMessages#importedMessage`

**Type**: `object`

A message from the room's earlier history.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `attachments` | `array` | No | Files attached to the message. |
| `author` | `ref` → `social.colibri.beta.bridge.defs#remoteAuthor` | Yes | Who sent the message. |
| `createdAt` | `string` (datetime) | Yes | When the message was sent on the other service. |
| `facets` | `array` | No | Annotations over ranges of the text. |
| `forward` | `ref` → `social.colibri.beta.message#forward` | No | Content forwarded from another Colibri message. |
| `parent` | `ref` → `social.colibri.beta.defs#recordRef` | No | The message this one replies to. |
| `remoteMessage` | `string` | Yes | The message's id on the other service. |
| `text` | `string` | Yes | The message body. |

### `social.colibri.beta.bridge.importMessages`

**Type**: `procedure`

Imports earlier messages from someone on another service into a linked channel or a thread beside it, after an admin asked for a history import. The community writes each message at its original time, and clients see them only when they load history.

#### Input

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `channel` | `string` (space-ref) | Yes | The linked channel, or a thread beside it, the messages go into. |
| `community` | `string` (did) | Yes | The community the registration belongs to. |
| `messages` | `array` | Yes | The messages, oldest first. |
| `registration` | `string` (tid) | Yes | Record key of the registration. |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `results` | `array` | Yes | One result per message, in input order. |

#### Errors

- **AuthRequired**: The request is missing, malformed, or unverifiable service auth.
- **CommunityNotFound**: No community exists at the given DID.
- **RegistrationNotFound**: The community has no bridge registration with that id.
- **Forbidden**: The caller is not the bridge this registration belongs to.
- **RegistrationDisabled**: An admin has paused this registration.
- **ChannelNotLinked**: The channel is not linked to this registration.
- **RateLimited**: The bridge sent too many requests. Retry after the interval in the response headers.
- **CredentialsUnavailable**: The AppView cannot act as the community because its stored credentials are missing or unusable.
- **BackfillNotRequested**: No admin has asked for a history import on this channel.
- **OutsideBackfillRange**: A message was sent before the requested range or after the request.

## Raw Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "importResult": {
      "description": "Where an imported message was written.",
      "properties": {
        "remoteMessage": {
          "description": "The message's id on the other service.",
          "maxLength": 256,
          "type": "string"
        },
        "rkey": {
          "description": "Record key of the record the community wrote.",
          "format": "record-key",
          "type": "string"
        }
      },
      "required": [
        "remoteMessage",
        "rkey"
      ],
      "type": "object"
    },
    "importedMessage": {
      "description": "A message from the room's earlier history.",
      "properties": {
        "attachments": {
          "description": "Files attached to the message.",
          "items": {
            "description": "A file uploaded earlier with uploadBlob.",
            "ref": "social.colibri.beta.message#attachment",
            "type": "ref"
          },
          "maxLength": 10,
          "type": "array"
        },
        "author": {
          "description": "Who sent the message.",
          "ref": "social.colibri.beta.bridge.defs#remoteAuthor",
          "type": "ref"
        },
        "createdAt": {
          "description": "When the message was sent on the other service.",
          "format": "datetime",
          "type": "string"
        },
        "facets": {
          "description": "Annotations over ranges of the text.",
          "items": {
            "description": "An annotation.",
            "ref": "social.colibri.beta.richtext.facet",
            "type": "ref"
          },
          "type": "array"
        },
        "forward": {
          "description": "Content forwarded from another Colibri message.",
          "ref": "social.colibri.beta.message#forward",
          "type": "ref"
        },
        "parent": {
          "description": "The message this one replies to.",
          "ref": "social.colibri.beta.defs#recordRef",
          "type": "ref"
        },
        "remoteMessage": {
          "description": "The message's id on the other service.",
          "maxLength": 256,
          "type": "string"
        },
        "text": {
          "description": "The message body.",
          "maxLength": 2048,
          "type": "string"
        }
      },
      "required": [
        "author",
        "text",
        "remoteMessage",
        "createdAt"
      ],
      "type": "object"
    },
    "main": {
      "description": "Imports earlier messages from someone on another service into a linked channel or a thread beside it, after an admin asked for a history import. The community writes each message at its original time, and clients see them only when they load history.",
      "errors": [
        {
          "description": "The request is missing, malformed, or unverifiable service auth.",
          "name": "AuthRequired"
        },
        {
          "description": "No community exists at the given DID.",
          "name": "CommunityNotFound"
        },
        {
          "description": "The community has no bridge registration with that id.",
          "name": "RegistrationNotFound"
        },
        {
          "description": "The caller is not the bridge this registration belongs to.",
          "name": "Forbidden"
        },
        {
          "description": "An admin has paused this registration.",
          "name": "RegistrationDisabled"
        },
        {
          "description": "The channel is not linked to this registration.",
          "name": "ChannelNotLinked"
        },
        {
          "description": "The bridge sent too many requests. Retry after the interval in the response headers.",
          "name": "RateLimited"
        },
        {
          "description": "The AppView cannot act as the community because its stored credentials are missing or unusable.",
          "name": "CredentialsUnavailable"
        },
        {
          "description": "No admin has asked for a history import on this channel.",
          "name": "BackfillNotRequested"
        },
        {
          "description": "A message was sent before the requested range or after the request.",
          "name": "OutsideBackfillRange"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "channel": {
              "description": "The linked channel, or a thread beside it, the messages go into.",
              "format": "space-ref",
              "type": "string"
            },
            "community": {
              "description": "The community the registration belongs to.",
              "format": "did",
              "type": "string"
            },
            "messages": {
              "description": "The messages, oldest first.",
              "items": {
                "description": "A message.",
                "ref": "#importedMessage",
                "type": "ref"
              },
              "maxLength": 25,
              "minLength": 1,
              "type": "array"
            },
            "registration": {
              "description": "Record key of the registration.",
              "format": "tid",
              "type": "string"
            }
          },
          "required": [
            "community",
            "registration",
            "channel",
            "messages"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "results": {
              "description": "One result per message, in input order.",
              "items": {
                "description": "A written message.",
                "ref": "#importResult",
                "type": "ref"
              },
              "type": "array"
            }
          },
          "required": [
            "results"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    }
  },
  "id": "social.colibri.beta.bridge.importMessages",
  "lexicon": 1
}
```
