> For the complete documentation index, see [llms.txt](https://docs.myjson.online/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.myjson.online/v1/endpoints/records.md).

# Records

{% hint style="warning" %}
myJson API V1 is deprecated. Please consider moving to the new [V2 API](https://docs.myjson.online/)
{% endhint %}

### Create

## Create a record.

<mark style="color:green;">`POST`</mark> `https://api.myjson.online/v1/records`

#### Headers

| Name                                           | Type          | Description                      |
| ---------------------------------------------- | ------------- | -------------------------------- |
| x-collection-access-token                      | String        |                                  |
| Content-Type<mark style="color:red;">\*</mark> |               |                                  |
| x-record-metadata                              | true \| false | default to true, return metadata |

#### Request Body

| Name                                           | Type   | Description                                             |
| ---------------------------------------------- | ------ | ------------------------------------------------------- |
| jsonData<mark style="color:red;">\*</mark>     | JSON   | Your json data                                          |
| collectionId<mark style="color:red;">\*</mark> | String | myJson [`collection`](/v1/terminology/collection.md) id |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    data: JSON,
    id: String
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    error: "Bad Request",
    message: "Invalid request"
}
```

{% endtab %}
{% endtabs %}

```javascript
// Javascript example
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
myHeaders.append("x-collection-access-token", "YOUR_COLLECTION_ACCESS_TOKEN");

var urlencoded = new URLSearchParams();
urlencoded.append("jsonData", `{"firstName": "Tim", "lastName": "Cook"}`);
urlencoded.append("collectionId", "YOUR_COLLECTION_ID");

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: urlencoded,
  redirect: 'follow'
};

fetch("https://api.myjson.online/v1/records", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

### Get

## Get a record

<mark style="color:blue;">`GET`</mark> `https://api.myjson.online/v1/records/:recordId`

#### Path Parameters

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| recordId<mark style="color:red;">\*</mark> | String |             |

#### Headers

| Name                                           | Type          | Description                      |
| ---------------------------------------------- | ------------- | -------------------------------- |
| Content-Type<mark style="color:red;">\*</mark> | String        |                                  |
| x-collection-access-token                      | String        |                                  |
| x-record-metadata                              | true \| false | default to true, return metadata |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    data: JSON,
    id: String
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

```javascript
// Javascript example
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("x-collection-access-token", "YOUR_COLLECTION_ACCESS_TOKEN");

var requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://api.myjson.online/v1/records/YOUR_RECORD_ID", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
```

### Get by version

<mark style="color:blue;">`GET`</mark> `https://api.myjson.online/v1/records/:recordId/versions/:version`

Get a record version

#### Path Parameters

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| recordId<mark style="color:red;">\*</mark> | String |             |
| version<mark style="color:red;">\*</mark>  | Number |             |

#### Headers

| Name                      | Type        | Description                      |
| ------------------------- | ----------- | -------------------------------- |
| x-collection-access-token | String      |                                  |
| x-record-metadata         | true\|false | default to true, return metadata |

{% tabs %}
{% tab title="200: OK " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="404: Not Found " %}

{% endtab %}
{% endtabs %}

```javascript
// Javascript example
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("x-collection-access-token", "YOUR_COLLECTION_ACCESS_TOKEN");

var requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://api.myjson.online/v1/records/YOUR_RECORD_ID/versions/VERSION_NUMBER", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
```

### Update

## Update a record

<mark style="color:orange;">`PUT`</mark> `https://api.myjson.online/v1/records/:recordId`

#### Path Parameters

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| recordId<mark style="color:red;">\*</mark> | String |             |

#### Headers

| Name                                           | Type          | Description                      |
| ---------------------------------------------- | ------------- | -------------------------------- |
| Content-Type<mark style="color:red;">\*</mark> | String        |                                  |
| x-collection-access-token                      | String        |                                  |
| x-record-metadata                              | true \| false | default to true, return metadata |

#### Request Body

| Name                                       | Type | Description |
| ------------------------------------------ | ---- | ----------- |
| jsonData<mark style="color:red;">\*</mark> | JSON |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    data: JSON,
    id: String
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

```javascript
// Javascript example
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
myHeaders.append("x-collection-access-token", "YOUR_COLLECTION_ACCESS_TOKEN");

var urlencoded = new URLSearchParams();
urlencoded.append("jsonData", `{"firstName": "Charles", "lastName": "Cook"}`);

var requestOptions = {
  method: 'PUT',
  headers: myHeaders,
  body: urlencoded,
  redirect: 'follow'
};

fetch("https://api.myjson.online/v1/records/YOUR_RECORD_ID", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

## Patch

## Update specific property of the record

<mark style="color:purple;">`PATCH`</mark> `https://api.myjson.online/v1/records/:recordId`

#### Path Parameters

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| recordId<mark style="color:red;">\*</mark> | String |             |

#### Headers

| Name                                           | Type          | Description                      |
| ---------------------------------------------- | ------------- | -------------------------------- |
| Content-Type<mark style="color:red;">\*</mark> | String        |                                  |
| x-collection-access-token                      | String        |                                  |
| x-record-metadata                              | true \| false | default to true, return metadata |

#### Request Body

| Name                                       | Type | Description |
| ------------------------------------------ | ---- | ----------- |
| jsonData<mark style="color:red;">\*</mark> | JSON |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    data: JSON,
    id: String
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

```javascript
// Javascript example
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
myHeaders.append("x-collection-access-token", "YOUR_COLLECTION_ACCESS_TOKEN");

var urlencoded = new URLSearchParams();
urlencoded.append("jsonData", `{"firstName": "Antoine"`);

var requestOptions = {
  method: 'PATCH',
  headers: myHeaders,
  body: urlencoded,
  redirect: 'follow'
};

fetch("https://api.myjson.online/v1/records/YOUR_RECORD_ID", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

### Delete

## Delete a record

<mark style="color:red;">`DELETE`</mark> `https://api.myjson.online/v1/records/:recordId`

#### Path Parameters

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| recordId<mark style="color:red;">\*</mark> | String |             |

#### Headers

| Name                                           | Type   | Description |
| ---------------------------------------------- | ------ | ----------- |
| Content-Type<mark style="color:red;">\*</mark> | String |             |
| x-collection-access-token                      | String |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    message: String
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

```javascript
// Javascript example
var myHeaders = new Headers();
myHeaders.append("x-collection-access-token", "YOUR_COLLECTION_ACCESS_TOKEN");

var urlencoded = new URLSearchParams();

var requestOptions = {
  method: 'DELETE',
  headers: myHeaders,
  body: urlencoded,
  redirect: 'follow'
};

fetch("https://api.myjson.online/v1/records/YOUR_RECORD_ID", requestOptions)
  .then(response => response.jsont())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```
