# Create a post-insert trigger on type

`POST /types/{typeId}/triggers/post-insert`



[Native Object Registry API guide](https://docs.contextual.io/legacy/tenants/tenant-apis/native-object-registry-api.md)

```json
{
  "openapi": "3.0.3",
  "info": {
    "title": "Native Object Registry Api",
    "description": " ",
    "version": "1.20.6"
  },
  "security": [
    {
      "jwt": []
    }
  ],
  "servers": [
    {
      "url": "https://native-object-registry.{tenantId}.my.contextual.io/api/v1",
      "variables": {
        "tenantId": {
          "default": "YOUR-TENANT-ID"
        }
      }
    }
  ],
  "paths": {
    "/types/{typeId}/triggers/post-insert": {
      "post": {
        "tags": [
          "Triggers"
        ],
        "summary": "Create a post-insert trigger on type",
        "parameters": [
          {
            "name": "typeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
            }
          },
          {
            "name": "x-if-hash-match",
            "in": "header",
            "required": false
          },
          {
            "name": "x-org-id",
            "in": "header",
            "required": false
          }
        ],
        "deprecated": false,
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "anyOf": [
                      {
                        "oneOf": [
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string",
                                "const": "system"
                              },
                              "name": {
                                "type": "string"
                              },
                              "description": {
                                "type": "string"
                              },
                              "action": {
                                "type": "string",
                                "const": "send-to-agent"
                              },
                              "agentId": {
                                "type": "string",
                                "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                              }
                            },
                            "required": [
                              "id",
                              "type",
                              "name",
                              "action",
                              "agentId"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string",
                                "const": "system"
                              },
                              "name": {
                                "type": "string"
                              },
                              "description": {
                                "type": "string"
                              },
                              "action": {
                                "type": "string",
                                "const": "echo"
                              }
                            },
                            "required": [
                              "id",
                              "type",
                              "name",
                              "action"
                            ],
                            "additionalProperties": false
                          }
                        ],
                        "type": "object"
                      },
                      {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "const": "custom"
                          },
                          "ruleSet": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string",
                                "minLength": 1
                              },
                              "id": {
                                "type": "string",
                                "format": "uuid",
                                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                              },
                              "description": {
                                "type": "string"
                              },
                              "functions": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "additionalProperties": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "format": "uuid",
                                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                                    },
                                    "params": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    },
                                    "block": {
                                      "$ref": "#/components/schemas/__schema0"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "params",
                                    "block"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "rules": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "name": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "id": {
                                      "type": "string",
                                      "format": "uuid",
                                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                                    },
                                    "description": {
                                      "type": "string"
                                    },
                                    "block": {
                                      "$ref": "#/components/schemas/__schema0"
                                    }
                                  },
                                  "required": [
                                    "name",
                                    "id",
                                    "block"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "name",
                              "id",
                              "rules"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "id",
                          "type",
                          "ruleSet"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "disabled": {
                        "type": "boolean"
                      }
                    },
                    "additionalProperties": false
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TriggerRef"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "Invalid payload provided": {
                "schema": {
                  "$ref": "#/components/schemas/$ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authorization header",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/$ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Invalid permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/$ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "jwt": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "__schema0": {
        "description": "The published OpenAPI schema does not define this component."
      },
      "TriggerRef": {
        "allOf": [
          {
            "anyOf": [
              {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "type": {
                        "type": "string",
                        "const": "system"
                      },
                      "name": {
                        "type": "string"
                      },
                      "description": {
                        "type": "string"
                      },
                      "action": {
                        "type": "string",
                        "const": "send-to-agent"
                      },
                      "agentId": {
                        "type": "string",
                        "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                      }
                    },
                    "required": [
                      "id",
                      "type",
                      "name",
                      "action",
                      "agentId"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "type": {
                        "type": "string",
                        "const": "system"
                      },
                      "name": {
                        "type": "string"
                      },
                      "description": {
                        "type": "string"
                      },
                      "action": {
                        "type": "string",
                        "const": "echo"
                      }
                    },
                    "required": [
                      "id",
                      "type",
                      "name",
                      "action"
                    ],
                    "additionalProperties": false
                  }
                ],
                "type": "object"
              },
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "const": "custom"
                  },
                  "ruleSet": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "minLength": 1
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      "description": {
                        "type": "string"
                      },
                      "functions": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "minLength": 1
                        },
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "params": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "block": {
                              "$ref": "#/components/schemas/__schema0"
                            }
                          },
                          "required": [
                            "id",
                            "params",
                            "block"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "rules": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string",
                              "minLength": 1
                            },
                            "id": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "description": {
                              "type": "string"
                            },
                            "block": {
                              "$ref": "#/components/schemas/__schema0"
                            }
                          },
                          "required": [
                            "name",
                            "id",
                            "block"
                          ],
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "name",
                      "id",
                      "rules"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "id",
                  "type",
                  "ruleSet"
                ],
                "additionalProperties": false
              }
            ]
          },
          {
            "type": "object",
            "properties": {
              "disabled": {
                "type": "boolean"
              }
            },
            "additionalProperties": false
          }
        ]
      },
      "$ErrorResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": [
              "string",
              "number"
            ]
          },
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {}
          }
        },
        "required": [
          "code",
          "message"
        ],
        "additionalProperties": false
      }
    }
  }
}
```