Create an export
How to create an export via API
To create a new export, send a POST request to the /api/exports endpoint, passing the resource arguments in the request body.
Request
POST https://yourdomain.commercelayer.io/api/exports
Arguments
Body Parameter
Type
Required
type
string
Required
attributes.resource_type
string
Required
attributes.format
string
Optional
attributes.includes
array
Optional
attributes.fields
array
Optional
attributes.filters
object
Optional
attributes.dry_data
boolean
Optional
attributes.reference
string
Optional
attributes.reference_origin
string
Optional
attributes.metadata
object
Optional
Example
The following request creates a new export:
curl -g -X POST \
  'https://yourdomain.commercelayer.io/api/exports' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "exports",
    "attributes": {
      "resource_type": "skus"
    }
  }
}'On success, the API responds with a 201 Created status code, returning the created resource object:
{
  "data": {
    "id": "XAyRWNUzyN",
    "type": "exports",
    "links": {
      "self": "https://yourdomain.commercelayer.io/api/exports/XAyRWNUzyN"
    },
    "attributes": {
      "resource_type": "skus",
      "format": "json",
      "status": "in_progress",
      "includes": [
        "prices.price_tiers"
      ],
      "fields": [
        "code",
        "name",
        "prices.*",
        "prices.price_tiers.price_amount_cents"
      ],
      "filters": {
        "code_eq": "AAA"
      },
      "dry_data": false,
      "started_at": "2018-01-01T12:00:00.000Z",
      "completed_at": "2018-01-01T12:00:00.000Z",
      "interrupted_at": "2018-01-01T12:00:00.000Z",
      "records_count": 300,
      "attachment_url": "http://cl_exports.s3.amazonaws.com/",
      "errors_log": {
        "RuntimeError": "query timeout"
      },
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANY-EXTERNAL-REFEFERNCE",
      "reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "events": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/exports/XAyRWNUzyN/relationships/events",
          "related": "https://yourdomain.commercelayer.io/api/exports/XAyRWNUzyN/events"
        }
      },
      "versions": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/exports/XAyRWNUzyN/relationships/versions",
          "related": "https://yourdomain.commercelayer.io/api/exports/XAyRWNUzyN/versions"
        }
      },
      "event_stores": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/exports/XAyRWNUzyN/relationships/event_stores",
          "related": "https://yourdomain.commercelayer.io/api/exports/XAyRWNUzyN/event_stores"
        }
      }
    },
    "meta": {
      "mode": "test",
      "organization_id": "xRRkjDFafe",
      "trace_id": "69abaa3545913c78132e5578bd26208d44aa9043647d78698fd0021f3958cd74"
    }
  }
}Last updated

