Schemas are one of the core pillars of Endgrate — when initiating a session, they are used to define exactly what formats of data you want to pull, push, or sync. Different integration providers have different data requirements, and schemas are used to standardize the flow so that you can deal with data in the exact format you want.

Schemas are defined using the JSON Schema Specification. If you are unfamiliar with the standard, here's a good introduction to how the standard works.

Endgrate's AI engine automatically handles the data standardization across all integration providers through a process known as field mapping. This process maps fields in your standardized schema to fields for specific integration providers. For example, a field first_name in your standardized schema might be mapped to a field firstname in HubSpot, and to a field FirstName in Salesforce.

The endgrate_type of a schema is a keyword such as crm-contact or crm-company that represents a certain resource within an integration provider. The endgrate_type lets Endgrate know what type of data the schema is supposed to represent.

If you don't want to create your own schema definition, you can use Endgrate's default standardized schemas for a given endgrate_type. In the following guides, we'll talk more about endgrate_types and what their corresponding default standardized schemas look like.

// By specifying the `type` and `properties` attributes,
// we can define our own custom standardized schema for
// crm-contact.
{
  "endgrate_type": "crm-contact",
  "type": "object",
  "properties": {
    "email": {
      "type": "string",
      "format": "email"
    },
    "first_name": {
      "type": "string"
    },
    "last_name": {
      "type": "string"
    },
    "full_name": {
      "type": "string"
    },
    "company": {
      "type": "string"
    },
    "age": {
      "type": "number"
    },
    "is_employed": {
      "type": "boolean"
    },
    "lifecyclestage": {
      "title": "Lifecycle Stage",
      "type": "string"
    }
  },
  "required": [
    "email"
  ],
  "title": "Contact"
}
// By omitting the `type` and `properties` of the schema,
// Endgrate will use the default standardized schema for 
// crm-contact defined here:
{
  "endgrate_type": "crm-contact"
}

When initiating a session, the schemas for your session should be put in a list under the schema body parameter.

curl --request POST \
     --url https://endgrate.com/api/session/initiate \
     --header 'accept: application/json' \
     --header 'authorization: Bearer API_KEY' \
     --header 'content-type: application/json' \
     --data '
{
  "schema": [
    // Defining our own custom standardized schema.
    {
    	"endgrate_type": "crm-contact",
      "type": "object",
      "properties": {
        "email": {
          "type": "string",
          "format": "email"
        },
        "full_name": {
          "type": "string"
        }
    },
    // Using Endgrate default standardized schema.
    {
    	"endgrate_type": "crm-company"
    }
  ]
}
'