# Post

## /v1/api

<mark style="color:green;">`POST`</mark> `https://next.cloudio.io/v1/api`

This endpoint allows you to perform insert, update & delete operations against one or more data sources

#### Query Parameters

| Name | Type   | Description              |
| ---- | ------ | ------------------------ |
| csrf | string | Auth response csrf value |

#### Headers

| Name           | Type   | Description                                                         |
| -------------- | ------ | ------------------------------------------------------------------- |
| Authentication | string | <p>Authentication token<br>JS e.g. `Bearer ${authResponse.jwt}`</p> |

#### Request Body

| Name         | Type   | Description                                          |
| ------------ | ------ | ---------------------------------------------------- |
| JSON Payload | string | See below for the structure/type of the body payload |

{% tabs %}
{% tab title="200 Rows successfully retrieved" %}

```javascript
{
  "status": "OK",
  "data": {
    "EmployeesAlias": {
      "data": [
        {
          "active": "Y",
          "createdBy": "userName",
          "creationDate": "2021-05-30T04:19:41.483732Z",
          "empId": 1004,
          "gender": "X",
          "lastUpdateDate": "2021-05-30T04:19:41.483732Z",
          "lastUpdatedBy": "userName",
          "name": "name value",
          "salary": 1,
          "_rs": "Q"
        }
      ],
    }
  }
}
```

{% endtab %}

{% tab title="400 Could not execute this query." %}

```
{
  "code": 400,
  "status": "ERROR",
  "title": "Invalid Request",
  "message": "reason for the error"
}
```

{% endtab %}
{% endtabs %}

## Sample Payloads

```javascript
{
    "EmployeesAlias": {
        "ds": "Employees",
        "data": [
            {
                "_rs": "I",
                "active": "Y",
                "gender": "X",
                "name": "name value",
                "salary": 1
            }
        ]
    }
}
```

```javascript
{
  "EmployeesAlias": {
    "ds": "Employees",
    "data": [
      { "_rs": "I", "name": "Steve" },
      { "_rs": "U", "empId": 999, ..., "lastUpdateDate": "2020-11-30T23:59:59.999Z" },
      { "_rs": "D", "empId": 123, ..., "lastUpdateDate": "2020-11-30T23:59:59.999Z" },
    ]
  }
}
```

#### Record Status \`\_rs\`

Every row must include a record status `_rs`. A value of `I` `U` & `D` indicates that the row must be inserted, updated & deleted respectively. Rows with `U` and `D` must accompany with all the primary key attributes & WHO columns, especially `lastUpdateDate` attribute.

#### Response: Record Status & WHO Columns

After successful post, all the records that are part of the request will be returned back with a records status of `Q` indicating Query status. Also, all the WHO columns (`createdBy`, `creationDate`, `lastUpdatedBy` & `lastUpdateDate`) will be populated with the current authenticated userName & server datetime values. Also the values may have changed by any pre and post insert/update scripts.

{% hint style="warning" %}
Note: The order of the rows in the response is not guaranteed to be in the same order as the request.
{% endhint %}

{% hint style="info" %}
Note: Any value passed for a non-updatable attribute will be ignored. The whole request will be rejected if any of attribute passed is not defined.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://next-docs.cloudio.io/rest-apis/post.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
