LogoLogo
  • Introduction
  • Features
  • Getting Started
    • Cortex User Guide
      • Organizations
      • Log in
      • Generate an API key
      • Make your first API request
      • Configure the org settings
      • Set up a data model
        • Create custom objects
        • Add custom properties
      • One-to-many relationships
      • Read and write data
      • Making a Request
      • Handling responses
      • Authentication
      • Two-factor authentication
      • Set third-party cookies
      • Connections
      • Upload files
      • Cortex iOS
      • Get started with Swift
      • Cortex service accounts
      • Cortex developer tools
      • Automated Account Notifications
  • Cortex API
    • Overview
    • Objects
      • Objects Overview
      • Organization
      • Account
      • Connections
      • Notifications
      • Stats
      • Logs
      • Export
      • Events
      • Room
    • Object Definition
      • Object Properties
        • Any
        • Binary
        • Boolean
        • Date
        • Document
        • File
        • Geometry
        • List
        • Number
        • ObjectId
        • Reference
        • String
    • Object Types
    • Access Control
    • Querying
      • Query Operators
      • Property Selection
      • Property Access
    • Aggregating
      • Aggregation Operators
    • Scripting
      • Script Types
      • Script Limits
      • ObjectId
      • CortexObject
        • Accounts
        • Views
      • Cursors
      • Operations
      • Script Modules
        • API Module
        • Base64 Module
        • Cache Module
        • Connections Module
        • Console Module
        • Consts Module
        • Counters Module
        • Crypto Module
        • HTTP Module
        • Logger Module
        • Notifications Module
        • Request Module
        • Response Module
        • SAML Module
        • Schemas Modules
        • Script Module
        • Session Module
        • Util.id Module
        • Util.ip Module
        • Util.paths Module
        • XML Module
        • Developer
        • Config
        • Renderer
        • SFTP
        • FTP
        • DB
          • Cursors
          • Driver
      • Static Methods
        • Accounts
        • Views
        • Cursors
      • Audit
      • Environments
      • HTTP Driver
      • Notifications
        • Firebase Cloud Messaging (FCM)
        • Tencent Push Notification Service Configuration
      • Televisit
      • Transforms
      • Localization
      • Available Javascript Libraries
    • Decorators
      • Runtime
        • Acl
        • As
        • Log
        • Profile
      • Static
        • Env
        • Job
        • Object
        • On
        • Policy
        • Route
        • Transform
        • Trigger
    • Expressions
      • Primer
      • Pipelines
      • Operators
      • Accumulators
      • Variables
      • Conditionals
      • Transforms
      • Triggers
      • On
      • Events
    • Faults
      • Fault Reference
  • Releases
    • Cortex Release Notes
      • Cortex API 2.28.3 (R3.4.6)
      • Cortex API 2.28.1 (R3.4.3)
      • Cortex API 2.27.2 (R3.4.1)
      • Cortex API 2.27.1 (R3.3.5)
      • SQL DB Connector 1.3.4 (R3.3.3)
      • Cortex API 2.26.2 (R3.3.1)
      • Cortex API 2.26.1 (R3.2.2)
      • Cortex API 2.26.0 (R3.2.1)
      • SQL DB Connector 1.3.3
      • Cortex API 2.25.0 (R3.1.1)
      • SQL DB Connector 1.3.2 (R3.1.0)
      • Cortex API 2.24.2 (R3.0.2)
      • SQL DB Connector 1.3.1 (R3.0.0)
      • Cortex API 2.24.1 (R2.3.3)
      • Cortex API 2.24.0 (R2.3.2)
      • SQL DB Connector 1.3.0 (R2.3.0)
      • Cortex API 2.23.0 (R2.2.4)
      • SQL DB Connector 1.2.0 (R2.2.0)
      • Cortex API 2.22.2 (R2.1.2)
      • Cortex API 2.22.1 and SQL DB Connector 1.1.1 (R2.0.1)
      • Cortex API 2.22.0
      • Cortex API 2.21.3
      • Cortex API 2.21.2
      • Cortex Web 4.16.0
      • Cortex Web 4.15.1
      • Cortex API 2.20.1
      • Cortex Web 4.14.0
      • Cortex Renderer 1.3.3
      • Cortex API 2.19.4
      • Cortex API 2.19.3 and Cortex Web 4.13.1
      • Cortex Renderer 1.3.2
      • Cortex API 2.19.1
      • Cortex API 2.18.0
      • Cortex API 2.17.6
      • Cortex API 2.17.5
      • Cortex API 2.17.4
      • Cortex API 2.17.3
      • Cortex API 2.17.2
      • Cortex API 2.17.1
      • Cortex API 2.16.0
      • Cortex API 2.15.9
      • Cortex API 2.15.8-1
      • Cortex 2.15.8
      • Cortex API 2.18.1
      • Cortex API 2.16.1
      • Cortex Renderer 1.3.1
      • Cortex Renderer 1.3.0
      • Cortex Renderer 1.2.2
      • Cortex Renderer 1.2.1
      • Cortex Renderer 1.2.0
    • Third-Party License Attribution

© 2025 Medable, Inc. All rights reserved.

On this page
  • Export Object Properties
  • List
  • Read
  • Create
  • Delete

Was this helpful?

  1. Cortex API
  2. Objects

Export

You can create data exports through the admin UI or directly through the API. Creating exports through the API is helpful when needing to automate an export process.

Export object instances define export jobs to run including details such as type of export, query and aggregation criteria, export paths to include, and more. Each export instance represents one specific export job. Export jobs are queued in the background and each org can run one job at a time. Although you can create as many export jobs as you'd like, they will run sequentially in the order they were created.

Exported data is archived in zip format and stored securely in an encrypted file store within Cortex. When the export job is complete, a secure download link will be provided in the export's dataFile property. This link can only be accessed by an authenticated user with administrator privileges. Exports are available for download for seven days, after which the export and archive are deleted.

Export archive sizes count against file storage limits in your org.

Export Object Properties

Name

Type

Description

label

String

The label for your export. This appears in the export jobs UI

description

String

The description of your export. If present, this appears in the export jobs UI

state

String

The current state of the export job. Can be pending, running, ready, error

exportFiles

Boolean

When selected, if the export contains files, they will be included along-side the exported data. Note, this can cause exports to take a long time to complete if there are many large files.

zipFiles

Boolean

Applies with exporting files. If true, files are archived together in a zip archive within the exported archive.

format

MIME-type

The format of the exported data. Valid types are: application/x-ndjson: New-line delimited JSON application/json: JSON format * text/csv: CSV format

objects

String

The plural name of the Cortex object being exported.

paths

String Array

Optional array of property names to include in the export. When no paths are provided, all non-optional paths are included.

include

String Array

An array of optional property names to be included in the export.

expand

String Array

An array of reference property names to be expanded in the export.

where

String

afterScript

String

A stringified custom script that will execute after export job completion. This is helpful for logging the completion of exports or sending notifications, etc.

principal

ObjectId

When set, the export runs as this principal. This is helpful when exports need to be limited by acl and when used in conjunction with a path prefix.

prefix

String

When a prefix is present the export can be limited to documents available in a write-through list or nested document array.

List

GET https://api.dev.medable.com/your_org_name/v2/exports

Path Parameters

Name
Type
Description

your_org_name

string

{
    "data": [
        {
            "_id": "595d68f40e74ad01008c52df",
            "access": 7,
            "created": "2017-07-05T22:32:20.753Z",
            "creator": {
                "_id": "5532e499540b0183799b4ee5",
                "object": "account",
                "path": "/accounts/5532e499540b0183799b4ee5"
            },
            "dataFile": {
                "ETag": "6d3ccfae24f5128b62525f33999525e0",
                "creator": "5532e499540b0183799b4ee5",
                "filename": "export-2017-07-05T22:32:21.228Z.json",
                "location": 4,
                "mime": "application/zip",
                "name": "content",
                "path": "/exports/595d68f40e74ad01008c52df/dataFile/content",
                "size": 353,
                "state": 2
            },
            "expiresAt": "2017-07-12T22:32:20.771Z",
            "format": "application/json",
            "label": "My Export",
            "object": "export",
            "objects": "c_goals",
            "owner": {
                "_id": "5532e499540b0183799b4ee5",
                "object": "account",
                "path": "/accounts/5532e499540b0183799b4ee5"
            },
            "state": "ready",
            "stats": {
                "docs": {
                    "count": 2
                },
                "files": {
                    "count": 0,
                    "size": 0
                }
            }
        },
        {
            "_id": "595d6b5a0e74ad01008c537a",
            "access": 7,
            "created": "2017-07-05T22:42:34.614Z",
            "creator": {
                "_id": "5532e499540b0183799b4ee5",
                "object": "account",
                "path": "/accounts/5532e499540b0183799b4ee5"
            },
            "dataFile": {
                "ETag": "7afba9849047dc37047c609b48c1020a",
                "creator": "5532e499540b0183799b4ee5",
                "filename": "export-2017-07-05T22:42:35.030Z.csv",
                "location": 4,
                "mime": "application/zip",
                "name": "content",
                "path": "/exports/595d6b5a0e74ad01008c537a/dataFile/content",
                "size": 910,
                "state": 2
            },
            "expiresAt": "2017-07-12T22:42:34.624Z",
            "format": "text/csv",
            "label": "My Export 2",
            "object": "export",
            "objects": "c_patients",
            "owner": {
                "_id": "5532e499540b0183799b4ee5",
                "object": "account",
                "path": "/accounts/5532e499540b0183799b4ee5"
            },
            "paths": [
                "_id",
                "created",
                "c_birthdate",
                "c_gender",
                "c_name"
            ],
            "state": "ready",
            "stats": {
                "docs": {
                    "count": 26
                },
                "files": {
                    "count": 0,
                    "size": 0
                }
            }
        }
    ],
    "hasMore": false,
    "object": "list"
}
$.ajax({
    url: "https://api.dev.medable.com/example/v2/exports",
    method: "GET",
    dataType : "json",
    xhrFields: {
        withCredentials: true
    },
    headers: {
        "Medable-Client-Key": "GsAqlhnIMzrDeD8V2MBQWq"
    }
}).done(function(data) {
    // ...
});

Read

GET https://api.dev.medable.com/your_org_name/v2/exports/export_id

Path Parameters

Name
Type
Description

your_org_name

string

export_id

string

{
  "_id": "595d68f40e74ad01008c52df",
  "access": 7,
  "created": "2017-07-05T22:32:20.753Z",
  "creator": {
    "_id": "5532e499540b0183799b4ee5",
    "object": "account",
    "path": "/accounts/5532e499540b0183799b4ee5"
  },
  "dataFile": {
    "ETag": "6d3ccfae24f5128b62525f33999525e0",
    "creator": "5532e499540b0183799b4ee5",
    "filename": "export-2017-07-05T22:32:21.228Z.json",
    "location": 4,
    "mime": "application/zip",
    "name": "content",
    "path": "/exports/595d68f40e74ad01008c52df/dataFile/content",
    "size": 353,
    "state": 2
  },
  "expiresAt": "2017-07-12T22:32:20.771Z",
  "format": "application/json",
  "label": "My Export",
  "object": "export",
  "objects": "c_goals",
  "owner": {
    "_id": "5532e499540b0183799b4ee5",
    "object": "account",
    "path": "/accounts/5532e499540b0183799b4ee5"
  },
  "state": "ready",
  "stats": {
    "docs": {
      "count": 2
    },
    "files": {
      "count": 0,
      "size": 0
    }
  }
}
$.ajax({
    url: "https://api.dev.medable.com/example/v2/exports/595d68f40e74ad01008c52df",
    method: "GET",
    dataType : "json",
    xhrFields: {
        withCredentials: true
    },
    headers: {
        "Medable-Client-Key": "GsAqlhnIMzrDeD8V2MBQWq"
    }
}).done(function(data) {
    // ...
});

Create

POST https://api.dev.medable.com/your_org_name/v2/exports

Path Parameters

Name
Type
Description

your_org_name

string

Request Body

Name
Type
Description

label

string

objects

string

format

string

exportFiles

boolean

zipFiles

boolean

{
  "_id": "595d6b5a0e74ad01008c537a",
  "object": "export",
  "created": "2017-07-05T22:42:34.614Z",
  "creator": {
    "_id": "5532e499540b0183799b4ee5",
    "object": "account",
    "path": "/accounts/5532e499540b0183799b4ee5"
  },
  "owner": {
    "_id": "5532e499540b0183799b4ee5",
    "object": "account",
    "path": "/accounts/5532e499540b0183799b4ee5"
  },
  "access": 7,
  "label": "test 3",
  "state": "pending",
  "exportFiles": false,
  "zipFiles": false,
  "format": "text/csv",
  "objects": "c_patients",
  "paths": [
    "_id", "created", "c_birthdate", "c_gender", "c_name"
  ],
  "afterScript": "import logger from 'logger';\nlogger.info(script.arguments.err || script.arguments.export);\n",
  "stats": {
    "docs": {
      "count": 0
    },
    "files": {
      "count": 0,
      "size": 0
    }
  },
  "expiresAt": "2017-07-12T22:42:34.624Z"
}
$.ajax({
    url: "https://api.dev.medable.com/example/v2/exports",
    method: "POST",
    dataType : "json",
    xhrFields: {
        withCredentials: true
    },
    headers: {
        "Medable-Client-Key": "GsAqlhnIMzrDeD8V2MBQWq"
    },
    data: {
      {
        "label": "My Export",
        "format": "text/csv",
        "objects": "c_patients",
        "paths": ["_id", "created", "c_birthdate", "c_gender", "c_name"],
        "afterScript": "import logger from 'logger';\nlogger.info(script.arguments.err || script.arguments.export);\n"
      }
		}
}).done(function(data) {
    // ...
});

Delete

DELETE https://api.dev.medable.com/your_org_name/v2/exports/export_id

Path Parameters

Name
Type
Description

your_org_name

string

export_id

string

{
    "object": "result",
    "data": true
}
$.ajax({
    url: "https://api.dev.medable.com/example/v2/connections/595d6b5a0e74ad01008c537a",
    method: "DELETE",
    dataType : "json",
    xhrFields: {
        withCredentials: true
    },
    headers: {
        "Medable-Client-Key": "GsAqlhnIMzrDeD8V2MBQWq"
    }
}).done(function(data) {
    // ...
});

Last updated 3 years ago

Was this helpful?

Optional query argument to filter the export. See the query argument for more details.

Where