> For the complete documentation index, see [llms.txt](https://docs.medable.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.medable.com/cortex-api/scripting/http-driver.md).

# HTTP Driver

## POST /:object/db/bulk

Performs a bulk operation, consisting of 1 or more driver operations. Bulk operations may be nested. For more information and examples, see [Bulk Operation](/cortex-api/scripting/http-driver.md) in the scripting section.

{% tabs %}
{% tab title="mdctl-cli" %}

```bash
$> mdctl api POST /accounts/db/bulk --file ./bulk-def.json --env=dev.example
```

{% endtab %}

{% tab title="Javascript" %}

```
$.ajax({
  url: 'https://api.dev.medable.com/example/v2/accounts/bulk',
  method: 'POST',
  dataType : 'json',
  xhrFields: {
    withCredentials: true
  },
  headers: {
    'Medable-Client-Key': 'GsAqlhnIMzrDeD8V2MBQWq'
  },
  data: [{       
    operation: 'updateOne',
    match: {
      email: 'me@example.com'
    },
    update: {
      $set: {
        c_field: true
      } 
    },
    output: false,
    halt: false
  }, {
    operation: 'cursor',
    where: {
      email: 'me@example.com'
    }         
  }]
}).done(function(data) {
  // ...
});
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": [
    {
      "_id": "5d44e9d78db1c88b69440f33",
      "data": {
        "_id": "5c7fe99ee8355a01008ff899",
        "object": "account"
      },
      "object": "operationResult",
      "path": "cursor[1][0]",
      "timestamp": 1564797399479
    }
  ],
  "hasMore": false,
  "object": "list"
}
```

{% endtab %}
{% endtabs %}

*Path Params*

* `object` { String } The object name.

*Body Params*

* `ops` { Object\[] } An array of bulk operations. &#x20;
  * `operation` { String } The operation name. Can be any one of the driver operations (bulk, readOne, cursor, etc.).
  * `object` { String = *undefined* } Sets a new object target for the operation.
  * `name` { String = *undefined* } Wrapped responses will be renamed to this from the operation name.
  * `halt` {Boolean = *true* } If false, an error will not halt the current bulk operation; Errors will instead be pushed to the output stream.
  * `output` {Boolean = *true* } If false, results are not pushed to the output stream.
  * `wrap` { Boolean = *true* } If false, the `operationResult` wrapper is removed from output documents. &#x20;
  * `*` { \* } Other individual operation options should be added to the operation object (ie. `match`, `where`, `pipeline`, `limit`, etc.)

*Header Params*

* `Accept` { String = *application-json* } The client can request `application/x-ndjson` to stream newline-delimited JSON documents.

*Response*

* { List } A list result.
  * `data` { OperationResult\[] } An array of wrapped results.
    * `_id` { ObjectID } The operation result identifier.
    * `data` { \* } The wrapped operation result.
    * `object` { String } The object name, `operationResult`.
    * `path` { String } The operation path in the form `operationName[operationIndex][cursorPosition]`.
    * `timestamp` { Number } The timestamp the operation result ws created, in milliseconds.&#x20;
  * `hasMore` { Boolean } `true` when more document exists past the cursor.&#x20;
  * `object` { String } `"list"`. &#x20;

## POST /:object/db/count

Count object instances.

*Path Params*

* `object` { String } The object name.

*Body Params*

* `accessLevel` { String|Number } If set, limits the count to those documents where the caller has at least `accessLevel`.
* `limit` { Number } If set, limits the maximum count.
* `locale` { String } Set the locale for the operation. This affect localized string matches.
* `maxTimeMS` { Number = 10000 } The maximum number of milliseconds the query is allowed to process before an initial cursor is opened.
* `skip` { Number } Skips `skip` documents.
* `where` { Object } A query match filter.

*Response*

* { Result } A result object.
  * `data` { Number } A document count.  &#x20;
  * `object` { String } `result`.&#x20;

## POST /:object/db/cursor

Stream a query or aggregation cursor.

*Path Params*

* `object` { String } The object name.

*Header Params*

* `Accept` { String = *application-json* } The client can request `application/x-ndjson` to stream newline-delimited JSON documents.

*Body Params*

* `accessLevel` { Number }
* `expand` { String\[] }
* `group` { Object }
* `include` { String\[] }
* `limit` { Number }
* `locale` { String }
* `map` { String }
* `maxTimeMS` { Number = 10000 }          &#x20;
* `paths` { String\[] }
* `passive` { Boolean = false }
* `pipeline` { Object\[] }
* `prefix` { String } A path to use when retrieving a cursor to a List within a readThrough path.&#x20;
* `skip` { Number }
* `sort` { Object }
* `where` { Object }&#x20;

*Response*

* { List } A list result.
  * `data` { \*\[] } Array of results.
  * `hasMore` { Boolean } `true` when more document exists past the cursor.&#x20;
  * `object` { String } `list`.&#x20;

##
