> For the complete documentation index, see [llms.txt](https://docs.plumvoice.com/insight/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.plumvoice.com/insight/api/adding-metadatabase-records.md).

# Adding Metadatabase Records

## Add Metadatabase Record(s)

<mark style="color:green;">`POST`</mark> `https://insight.plumvoice.com/api/metadatabase_push`

Add metadatabase records to a Plum Insight survey.

#### Headers

| Name         | Type   | Description                       |
| ------------ | ------ | --------------------------------- |
| content-type | string | application/x-www-form-urlencoded |

#### Request Body

| Name         | Type   | Description                                                                                                                                                                                                                                          |
| ------------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| metadatabase | string | The name of the metadatabase. This is case-insensitive.                                                                                                                                                                                              |
| record       | string | json encoded associative array of the column names and column values to be added. Example: {'column1': 'value1', 'column2': 'value2'} This need not include all columns, you can leave out columns in your metadatabase you do not wish to populate. |

{% tabs %}
{% tab title="200 " %}
{% tabs %}
{% tab title="JSON" %}

```javascript
{'success':true}
```

{% endtab %}

{% tab title="XML" %}

```markup
<result>
  <success>true</success>
</result>
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="404 Example: The specified metadatabase did not exist." %}
{% tabs %}
{% tab title="JSON" %}

```javascript
{'success':false,'error':'No metadatabase by that name exists.'}
```

{% endtab %}

{% tab title="XML" %}

```markup
<result>
  <success>false</success
  <error>No metadatabase by that name exists.</error>
</result>
```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

### **Possible Response Codes**

* **200**: success
* **400**: invalid data supplied
* **401**: authentication headers invalid or the account is inactive
* **404**: metadatabase was not found
* **405**: invalid HTTP method supplied (only POST allowed)
* **415**: unsupported media type (Content-Type value in request)
* **500**: database error

The return structure contains the following item(s):

| Name    | Data Type | Always Present | Description                                                                             |
| ------- | --------- | -------------- | --------------------------------------------------------------------------------------- |
| success | boolean   | yes            | Indicates the outcome of the request                                                    |
| error   | string    | no             | If the success value is false this provides a message indicating what error(s) occurred |

### **Sample Code**

This sample PHP code makes a request to push a new record into the 'test' metadatabase and sets values for columns column1 and column2:

```php
<?php

$params = array(
	'metadatabase' => 'test',
	'record' => json_encode(array('column1' => 'value1', 'column2' => 'value2')),
	);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://insight.plumvoice.com/api/metadatabase_push");
curl_setopt($ch, CURLOPT_USERPWD, 'your_login:your_dev_pin'); // http basic auth credentials
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'Accept: application/json'));
$result = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
var_dump($http_code, $result);
```
