# Attach or create a subrecord

Hang a child record under this one. Pass childKey plus childRowId to attach an EXISTING record, or childKey plus cells to create a new child on that page and attach it in one transaction. The child page must be one this page accepts (see GET /v1/definitions/:key/child-pages), and the database refuses an undeclared pair.

Access class: `def:read`.

## Endpoint

`POST /v1/definitions/{key}/rows/{rowId}/subrecords`

## Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| key | path | string | Yes |
| rowId | path | string | Yes |

## Request body

Content type: `application/json`.

```json
{
  "body": {
    "cells": {},
    "childKey": "string",
    "childRowId": "",
    "position": 1
  },
  "params": {
    ":key": "string",
    ":rowId": ""
  },
  "query": {}
}
```

## Responses

### 201

the action's answer

Content type: `application/json`.

```json
{
  "data": {
    "cells": {},
    "childKey": "string",
    "childName": "string",
    "childRowId": "",
    "createdAt": "string",
    "createdByUserId": 1,
    "id": "",
    "kind": "string",
    "position": 1
  }
}
```

### default

a refusal: `{"error": "<what a person needs to read>"}`. 401 no credential, 402 the plan does not include this, 403 the seat does not, 404 the thing does not exist or is not yours to see.

Content type: `application/json`.

```json
{
  "error": "string"
}
```
