Skip to main content

Schema Templates

Data schema resources define the structure of data. Data schemas may or may not be associated with a specific data set.

Templates

A data schema can be saved as a template, which can be copied to create new data schemas that can be associated with specific data sets. A template data schema itself cannot be directly associated with a data set. Once a data schema is created from a template, it is not affected by subsequent changes to the template.

List All Schemas

You can make a request to list all of the data schemas owned by the authenticated user. A successful request returns with status 200 and a JSON response containing an array of data schema objects.

List All Schemas: Request
GET /data_schemas
List All Schemas: Response
[
{
"id": 1,
"owner": {
"id": 2,
"full_name": "Jeffrey Williams",
"email": "jcw@nexla.com"
},
"org": {
"id": 1,
"name": "Nexla",
"email_domain": "nexla.com",
"email": null
},
"version": 3,
"name": "Sample Schema (no data set)",
"description": null,
"access_roles": ["owner"],
"detected": false,
"managed": true,
"template": false,
"schema": {
"properties": {
"a": {
"type": "number"
},
"b": {
"type": "string"
},
"c": {
"properties": {
"d": {
"type": "string"
},
"e": {
"type": "number"
},
"g": {
"type": "string"
}
},
"type": "object"
},
"f": {
"type": "number"
}
},
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema-id": 1096894896
},
"annotations": {},
"validations": {},
"data_samples": [],
"tags": [],
"updated_at": "2019-04-19T21:56:55.000Z",
"created_at": "2019-04-18T21:45:01.000Z"
},
{
"id": 2,
"owner": {
"id": 2,
"full_name": "Jeffrey Williams",
"email": "jcw@nexla.com"
},
"org": {
"id": 1,
"name": "Nexla",
"email_domain": "nexla.com",
"email": null
},
"version": 4,
"name": "Sample Schema (Cloned)",
"description": null,
"access_roles": ["owner"],
"detected": false,
"managed": false,
"template": true,
"schema": {
"properties": {
"a": {
"type": "number"
},
"b": {
"type": "string"
},
"c": {
"properties": {
"d": {
"type": "string"
},
"e": {
"type": "number"
},
"g": {
"type": "string"
}
},
"type": "object"
},
"f": {
"type": "number"
}
},
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema-id": 1096894896
},
"annotations": {},
"validations": {},
"data_samples": [],
"tags": [],
"updated_at": "2019-04-22T22:22:32.000Z",
"created_at": "2019-04-22T22:22:32.000Z"
}
]

List Schemas By Template Settings

To list only those data schemas marked as templates, include the template=1 query parameter . Similarly, pass 0 or false to list only those data schemas that are not templates.

List Schemas By Template Settings: Request
GET /data_schemas?template=1
List Schemas By Template Settings: Response
{
"id": 2,
"owner": {
"id": 2,
"full_name": "Jeffrey Williams",
"email": "jcw@nexla.com"
},
"org": {
"id": 1,
"name": "Nexla",
"email_domain": "nexla.com",
"email": null
},
"version": 4,
"name": "Sample Schema (Cloned)",
"description": null,
"access_roles": ["owner"],
"detected": false,
"managed": false,
"template": true,
"schema": {
"properties": {
"a": {
"type": "number"
},
"b": {
"type": "string"
},
"c": {
"properties": {
"d": {
"type": "string"
},
"e": {
"type": "number"
},
"g": {
"type": "string"
}
},
"type": "object"
},
"f": {
"type": "number"
}
},
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema-id": 1096894896
},
"annotations": {},
"validations": {},
"data_samples": [],
"tags": [],
"updated_at": "2019-04-22T22:22:32.000Z",
"created_at": "2019-04-22T22:22:32.000Z"
}

Show One Schema

Issue a GET request to the /data_schemas/<data_schema_id> endpoint to retrieve a specific data schema. Include the the expand=1 query parameter to receive details about any data sets to which the schema is associated.

Show One Schema: Request
GET /data_schemas/{data_schema_id}?expand=1
Show One Schema: Response
{
"id": 1,
"owner": {
"id": 2,
"full_name": "Jeffrey Williams",
"email": "jcw@nexla.com"
},
"org": {
"id": 1,
"name": "Nexla",
"email_domain": "nexla.com",
"email": null
},
"version": 3,
"name": null,
"description": null,
"access_roles": ["owner"],
"detected": true,
"managed": false,
"schema": {
"properties": {
"a": {
"type": "number"
},
"b": {
"type": "string"
},
"c": {
"properties": {
"d": {
"type": "string"
},
"e": {
"type": "number"
},
"g": {
"type": "string"
}
},
"type": "object"
},
"f": {
"type": "number"
}
},
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema-id": 1096894896
},
"annotations": {},
"validations": {},
"data_samples": [],
"data_sets": [5266],
"tags": [],
"updated_at": "2019-04-19T21:56:55.000Z",
"created_at": "2019-04-18T21:45:01.000Z"
}

Create A Schema Template

Nexla provides multiple ways for creating a desired schema template.

Create from Specification

You can create a desired schema by providing a schema specification.

Create Schema from Specification: Request
POST /data_schemas
...
Example Request Body
{
"name": "Sample Schema",
"schema": {
"properties": {
"X": {
"type": "number"
},
"XX": {
"type": "number"
},
"Y": {
"type": "string"
}
},
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema-id": 689554280
},
"annotations": {
"properties": {
"X": {
"description": "A scalar value"
},
"Y": {
"description": "A string value"
}
},
"type": "object"
}
}
Create Schema from Specification: Response
{
"id": 5,
"owner": {
"id": 2,
"full_name": "Jeffrey Williams",
"email": "jcw@nexla.com"
},
"org": {
"id": 1,
"name": "Nexla",
"email_domain": "nexla.com",
"email": null
},
"version": 7,
"name": "Sample Schema",
"description": null,
"access_roles": ["owner"],
"detected": true,
"managed": false,
"schema": {
"properties": {
"X": {
"type": "number"
},
"XX": {
"type": "number"
},
"Y": {
"type": "string"
}
},
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema-id": 689554280
},
"annotations": {
"properties": {
"X": {
"description": "A scalar value"
},
"Y": {
"description": "A string value"
}
},
"type": "object"
},
"validations": {},
"data_samples": [],
"data_sets": [],
"tags": [],
"updated_at": "2019-04-23T14:23:41.821Z",
"created_at": "2019-04-23T14:23:41.821Z"
}

Create from Existing Data Schema

You can copy an existing schema into a new schema template. To copy an existing data schema, provide request body containing one attribute, data_schema_id, set to the id of the schema to copy. Optionally, set the template attribute to true to make the copy a template data schema (default is false).

Create from Existing Schema: Request
POST /data_schemas
...
Example Request Body
{
"data_schema_id": 1,
"template": true
}
Create from Existing Schema: Response
{
"id": 5,
"owner": {
"id": 2,
"full_name": "Jeffrey Williams",
"email": "jcw@nexla.com"
},
"org": {
"id": 1,
"name": "Nexla",
"email_domain": "nexla.com",
"email": null
},
"version": 7,
"name": "Sample Schema",
"description": null,
"access_roles": ["owner"],
"detected": true,
"managed": false,
"schema": {
"properties": {
"X": {
"type": "number"
},
"XX": {
"type": "number"
},
"Y": {
"type": "string"
}
},
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema-id": 689554280
},
"annotations": {
"properties": {
"X": {
"description": "A scalar value"
},
"Y": {
"description": "A string value"
}
},
"type": "object"
},
"validations": {},
"data_samples": [],
"data_sets": [],
"tags": [],
"updated_at": "2019-04-23T14:23:41.821Z",
"created_at": "2019-04-23T14:23:41.821Z"
}

Create from Existing Dataset

To create a data schema using the output schema of an existing dataset, use request body containing one attribute, data_set_id, set to the id of dataset whose schema you wish to copy. Note that dataset associations are not copied.

Create from Existing Dataset: Request
POST /data_schemas
...
Example Request Body
{
"data_set_id": 5251
}
Create from Existing Schema: Response
{
"id": 5,
"owner": {
"id": 2,
"full_name": "Jeffrey Williams",
"email": "jcw@nexla.com"
},
"org": {
"id": 1,
"name": "Nexla",
"email_domain": "nexla.com",
"email": null
},
"version": 7,
"name": "Sample Schema",
"description": null,
"access_roles": ["owner"],
"detected": true,
"managed": false,
"schema": {
"properties": {
"X": {
"type": "number"
},
"XX": {
"type": "number"
},
"Y": {
"type": "string"
}
},
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema-id": 689554280
},
"annotations": {
"properties": {
"X": {
"description": "A scalar value"
},
"Y": {
"description": "A string value"
}
},
"type": "object"
},
"validations": {},
"data_samples": [],
"data_sets": [],
"tags": [],
"updated_at": "2019-04-23T14:23:41.821Z",
"created_at": "2019-04-23T14:23:41.821Z"
}