# API: Entity mappings

| Method | Path | What it does | Scope |
|---|---|---|---|
| GET | `/v1/entity-mappings` | Names and domains from sources mapped (or proposed to map) to accounts. Approve a proposal once and every later item with that value goes there. | `records:read` |
| POST | `/v1/entity-mappings` | Map a value a source uses (an email domain, an import's company name) to an account yourself | `records:write` |
| POST | `/v1/entity-mappings/:id/approve` | Approve a proposal (or pick another account). Later items with this value map there; the account made for it meanwhile is merged in unless merge_created is false. | `records:write` |
| POST | `/v1/entity-mappings/:id/reject` | Not the same: the value stays its own account and isn't proposed again | `records:write` |

## Examples

### GET /v1/entity-mappings

Names and domains from sources mapped (or proposed to map) to accounts. Approve a proposal once and every later item with that value goes there.

```bash
curl -s "https://api.closefinch.com/v1/entity-mappings" \
  -H "Authorization: Bearer $RA_API_KEY"
```

```js
const res = await fetch(`https://api.closefinch.com/v1/entity-mappings`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.RA_API_KEY}` },
});
const data = await res.json();
```

### POST /v1/entity-mappings

Map a value a source uses (an email domain, an import's company name) to an account yourself

```bash
curl -s -X POST "https://api.closefinch.com/v1/entity-mappings" \
  -H "Authorization: Bearer $RA_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.closefinch.com/v1/entity-mappings`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.RA_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### POST /v1/entity-mappings/$ID/approve

Approve a proposal (or pick another account). Later items with this value map there; the account made for it meanwhile is merged in unless merge_created is false.

```bash
curl -s -X POST "https://api.closefinch.com/v1/entity-mappings/$ID/approve" \
  -H "Authorization: Bearer $RA_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.closefinch.com/v1/entity-mappings/${id}/approve`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.RA_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### POST /v1/entity-mappings/$ID/reject

Not the same: the value stays its own account and isn't proposed again

```bash
curl -s -X POST "https://api.closefinch.com/v1/entity-mappings/$ID/reject" \
  -H "Authorization: Bearer $RA_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.closefinch.com/v1/entity-mappings/${id}/reject`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.RA_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

Request and response schemas: [https://www.closefinch.com/openapi.json](https://www.closefinch.com/openapi.json). All resources: [API reference](https://www.closefinch.com/docs/api).
