# Developer

```javascript
const developer = require('developer')
```

The Developer module exposes various developer-centric environment functionality.

{% hint style="info" %}
This module is available on development endpoints.
{% endhint %}

## module developer.sessions

```javascript
const { sessions } = require('developer')
```

### logout(account)

Logs out sessions for an account. If called from a script by the target account during a session and the current session is in the context of the calling request, the caller's session is not closed.

Once closed, the first authenticated access by the target account for any existing sessions results in a `cortex.accessDenied.loggedInElsewhere` fault.

*Arguments*

* `account` { String | ObjectID } The account email or ID of the target for which sessions are forcibly ended.

## module developer.locations

```javascript
const { locations } = require('developer')
```

### list({ where, pipeline, sort, skip, limit })

Queries environment devices.

*Arguments*

* `options` { Object }
  * `where` { Object } A query match object.
  * `pipeline` { Object } An aggregation pipeline object.   &#x20;
  * `sort` { Object } A query sort object.
  * `skip` { Number = 0 }
  * `limit` { Number = Undefined }

*Returns*

* `list` { Object } A list object.
  * `hasMore` { Boolean } **`true`** for more results.
  * `data` { Object\[] } An array of location objects.
  * `object` { String } `"list"`.

### remove( \_id )

Removes a device location by `_id`.

*Arguments*

* `_id` { ObjectID } The ID of the device location to be removed.

*Returns*

* `location` { Object } The location object removed. Returns `cortex.notFound.unspecified` error if not found.

## module developer.environment

View the [mdctl-cli](https://github.com/Medable/mdctl/blob/master/packages/mdctl-cli/README.md#environments) GitHub topic for more information about environment import and export.

The following updates are made to Cortex's environment import process in Cortex API 2.17.0:

* Policies are disabled during import and package install.
* Backups and triggers are **false** by default during import.
* Memo parameter is accessible during ingest and export pipes.
* Memo parameter is accessible to the **beforeImport**, **afterImport**, **beforeExport**, **afterExport** scripts.

### Include

```javascript
const { environment } = require('developer')
```

### export(options)

Exports an environment.

*Arguments*

* `options` { Object }
  * `manifest` { Object } A manifest definition that determines what to export.
  * `preferUrls` { Boolean = true } When **`true`**, exports signed URLs for file data where possible. When **false**,

    file data is base64-encoded into chunked resource `stream` objects.
  * `silent` { Boolean = false } When **`true`**, manifest entries without unique keys will be ignored. By default, a `cortex.unsupportedOperation.uniqueKeyNotSet` fault is occurs.

*Returns*

* { Cursor } A cursor to output documents.

### import(payload, options)

Imports to an environment.

*Arguments*

* `payload` { Cursor | Object\[] } An import stream of documents defining the import (manifest and resources).
* `options` { Object }
  * `backup` { Boolean = true } When **`true`**, the deployment mechanism puts the environment into maintenance mode and forces a wholesale rollback if an import error occurs.
  * `triggers` { Boolean = true } When set to **false**, script triggers for updated or inserted resources are skipped.
  * `production` { Boolean = false } In the future, script-based imports may be allowed in production. As a safety measure, the production flag must be set when in production and only when in production.

*Returns*

* { Cursor } A cursor to input result documents.

## Examples

### Export a definition

```javascript
const { environment } = require('developer')

return environment.export({
  manifest: {            
    objects: [{
      name: 'c_example',
      includes: ['*']
    }]
  }
})
```


---

# 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://docs.medable.com/cortex-api/scripting/modules-1/developer.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.
