# Contact routes: enrich, enroll, merge

URL: /code/api/contact/verbs · Id: `page:code/api/contact/verbs`

> The Contact Verbs enrich, enroll, merge as api.sb routes, with inputs, result, refusals and an example.

Reference for [Contact](/business/nouns/contact), one group of [Contact routes](/code/api/contact).

### Contact.enrich
Enrich fills a Contact’s missing fields from outside sources and marks each value with where it came from. [Verb page](/business/nouns/contact/enrich?interface=api).

```text
POST /{namespace}/contacts/{contact}/enrich
```

Path: `contact`. Emits [`Contact.enriched`](/business/events/Contact.enriched).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `contact` | [Contact](/business/nouns/contact) | Yes | The Contact to enrich. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `contact` | [Contact](/business/nouns/contact) | Yes | The enriched Contact. |

**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**

```bash
curl -X POST https://api.sb/leaseline.app/contacts/contact_WsrosCQi6J/enrich \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "contact": {
    "$id": "https://api.sb/leaseline.app/contacts/contact_WsrosCQi6J",
    "$type": "Contact",
    "email": "marcus@riversideproperty.com",
    "phone": "Example phone"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Contact.enrich",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### Contact.enroll
Enroll adds a Contact to a Sequence, which sends its steps until the Contact replies or exits. [Verb page](/business/nouns/contact/enroll?interface=api).

```text
POST /{namespace}/contacts/{contact}/enroll
```

Path: `contact`. Body, as JSON: the other inputs. Emits [`Contact.enrolled`](/business/events/Contact.enrolled).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `contact` | [Contact](/business/nouns/contact) | Yes | The Contact to enroll. |
| `sequence` | [Sequence](/business/nouns/sequence) | Yes | The Sequence to run. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `contact` | [Contact](/business/nouns/contact) | Yes | The enrolled Contact. |
| `enrollment` | [Enrollment](/business/nouns/enrollment) | Yes | The Enrollment that records this Contact’s run through the Sequence. |

**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. |
| The record is not in a state that allows this Verb, so the call is refused. | [`refused`](/code/api/errors/refused) | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |
| A suppressed Contact or one with no consent for the Sequence’s purpose | [`refused`](/code/api/errors/refused) | Clear what the check names, then call it again. | None. |

**Example**

```bash
curl -X POST https://api.sb/leaseline.app/contacts/contact_WsrosCQi6J/enroll \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sequence":"sequence_H7knHGrBdP"}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "contact": {
    "$id": "https://api.sb/leaseline.app/contacts/contact_WsrosCQi6J",
    "$type": "Contact",
    "email": "marcus@riversideproperty.com",
    "phone": "Example phone"
  },
  "enrollment": {
    "$id": "https://api.sb/leaseline.app/enrollments/enrollment_t2LKaLorKn",
    "$type": "Enrollment",
    "status": "active",
    "step": "Example step"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Contact.enroll",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### Contact.merge
Merge joins a duplicate Contact into another, keeping every link, Message and Event on the one that remains. [Verb page](/business/nouns/contact/merge?interface=api).

```text
POST /{namespace}/contacts/{contact}/merge
```

Path: `contact`. Body, as JSON: the other inputs. Emits [`Contact.merged`](/business/events/Contact.merged).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `contact` | [Contact](/business/nouns/contact) | Yes | The duplicate. |
| `into` | [Contact](/business/nouns/contact) | Yes | The Contact that remains. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `contact` | [Contact](/business/nouns/contact) | Yes | The remaining Contact. |

**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**

```bash
curl -X POST https://api.sb/leaseline.app/contacts/contact_WsrosCQi6J/merge \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"into":"contact_WsrosCQi6J"}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "contact": {
    "$id": "https://api.sb/leaseline.app/contacts/contact_WsrosCQi6J",
    "$type": "Contact",
    "email": "marcus@riversideproperty.com",
    "phone": "Example phone"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Contact.merge",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```