POST /datasets

Description

Create a new dataset and define the dataset schema.

📣

The schema provided should be an exact representation of the dataset you are loading. All schema properties must be present in the dataset file you are loading.

This API call should be made before loading a new dataset to the Dataset Exchange API. The API call will return the ID of your newly defined dataset, which you will need for subsequent API calls.

Parameters

ParameterTypeDescriptionNote
namestringName of datasetRequired
descriptionstringShort description of datasetOptional
schemaobjectMust indicate a primary key and include schema properties.Required
primaryKeyarrayAn array of schema property names that will act as the primary key(s) of each dataset record. The value for each should be guaranteed unique. primaryKey needs to have, at minimum, one value.Required - A minimum of one value
propertiesarrayAn array of objects with name, required and type properties. Valid type values are: string, boolean and integer. See example below.Required
tagIdsarrayArray of IDs to indicate a permission tag for accessing the dataset. Available IDs can be found at GET /datasets/tags as movementAppIdOptional

URL Structure

https://app.movementinfrastructure.org/api/v1/datasets

Example Request Body

{
    "name": "October Door Knocking",
    "description": "All of the doors for knocking",
    "schema":  {
        "primaryKey": ["van_id"],
        "properties": [
            {
              "name": "van_id",
              "required": true,
              "type": "string"
            },
            {
              "name": "first_name",
              "required": true,
              "type": "string"
            },
            {
              "name": "last_name",
              "required": true,
              "type": "string"
            },
            {
              "name": "knock_count",
              "required": true,
              "type": "integer"
            },
            {
              "name": "answered_door",
              "required": true,
              "type": "boolean"
            }
        ]
     }
   },
  "tagIds": [{"movementAppId": "89ex3a5-mpl3-43f0-e198-x45a9m58p1ee"}]
}

Example Response Body

{
   "datasetId": "812e3xam4-5678-91ple-abdc-312692jk2lm",
   "name": "October Door Knocking",
   "description": "All of the doors for knocking",
   "dateCreated": "2024-08-21T15:41:03.07133",
   "recordCount": 10000,
   "dateLastRecordUpdated": null,
   "createdBy": {
        "userId": 11111,
        "displayName": "My Test DXAPI App",
        "email": ""
    },
    "createdByWorkspace": {
       "workspaceId": 1235643,
       "displayName": "Soledad for Governor"
    },
    "datasetTags": [
    {
      "datasetTagId":"3xam112-p346-7789-89pl-876e6q43aa2b",
      "name":"Example Texting Tool App",
      "movementAppId":"11ex3a3-mpl3-43e0-o198-n45e9a58b1cd"
     },
     {
       "datasetTagId":"3xam112-p123-4456-89pl-987e6q54aa5b",
       "name":"My Test DXAPI App",
       "movementAppId":"89ex3a5-mpl3-43f0-e198-x45a9m58p1ee"
     }
  ],
}