Skip to content

Docs

POST /save_template

https://heyeveryone.ai/api/v1/save_template

Operation

{
  "post": {
    "description": "Create or edit a recurring content format. Without `templateId` it creates one: `name` and `titlePattern` are required, plus the original draft (`masterText`), optional `campaignLabels`, and `channels`: the channel accounts (list_channel_accounts) to create a draft post for, each with an optional `format` and optional `segments` (its own text, several for a thread; left out: start from the original draft). With `templateId` it changes only the fields you send (`description: null` clears it); `channels`, when sent, replaces the whole list. Content already created from it doesn't change. Placeholders are written `{name}` (a letter first; letters, digits, spaces, `_` or `-`), for example `{product}` or `{episode number}`; the template's `placeholders` lists them, and create_content_from_template fills them from `values`. Names are unique in the workspace (`name_taken`). A template only creates drafts; nothing is scheduled or published from it.",
    "operationId": "save_template",
    "requestBody": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "workspaceId": {
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
                "type": "string"
              },
              "templateId": {
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
                "type": "string"
              },
              "name": {
                "maxLength": 120,
                "minLength": 1,
                "type": "string"
              },
              "description": {
                "anyOf": [
                  {
                    "maxLength": 500,
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "titlePattern": {
                "maxLength": 300,
                "minLength": 1,
                "type": "string"
              },
              "masterText": {
                "maxLength": 100000,
                "type": "string"
              },
              "campaignLabels": {
                "items": {
                  "maxLength": 60,
                  "minLength": 1,
                  "type": "string"
                },
                "maxItems": 10,
                "type": "array"
              },
              "channels": {
                "items": {
                  "properties": {
                    "channelAccountId": {
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
                      "type": "string"
                    },
                    "format": {
                      "anyOf": [
                        {
                          "pattern": "^[a-z][a-z0-9_]*$",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "segments": {
                      "anyOf": [
                        {
                          "items": {
                            "maxLength": 100000,
                            "type": "string"
                          },
                          "maxItems": 25,
                          "minItems": 1,
                          "type": "array"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "channelAccountId"
                  ],
                  "type": "object"
                },
                "maxItems": 20,
                "type": "array"
              }
            },
            "required": [
              "workspaceId"
            ],
            "type": "object"
          }
        }
      },
      "required": true
    },
    "responses": {
      "200": {
        "content": {
          "application/json": {
            "schema": {
              "additionalProperties": false,
              "properties": {
                "template": {
                  "additionalProperties": false,
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "titlePattern": {
                      "type": "string"
                    },
                    "masterText": {
                      "type": "string"
                    },
                    "campaignLabels": {
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "channels": {
                      "items": {
                        "additionalProperties": false,
                        "properties": {
                          "channelAccountId": {
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
                            "type": "string"
                          },
                          "platform": {
                            "enum": [
                              "x",
                              "linkedin",
                              "threads",
                              "bluesky",
                              "instagram",
                              "facebook",
                              "tiktok",
                              "youtube",
                              "sandbox"
                            ],
                            "type": "string"
                          },
                          "handle": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "displayName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "status": {
                            "enum": [
                              "active",
                              "reconnect_required",
                              "disconnected"
                            ],
                            "type": "string"
                          },
                          "format": {
                            "anyOf": [
                              {
                                "pattern": "^[a-z][a-z0-9_]*$",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "segments": {
                            "anyOf": [
                              {
                                "items": {
                                  "type": "string"
                                },
                                "type": "array"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "channelAccountId",
                          "platform",
                          "handle",
                          "displayName",
                          "status",
                          "format",
                          "segments"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "placeholders": {
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "createdAt": {
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
                      "type": "string"
                    },
                    "updatedAt": {
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "description",
                    "titlePattern",
                    "masterText",
                    "campaignLabels",
                    "channels",
                    "placeholders",
                    "createdAt",
                    "updatedAt"
                  ],
                  "type": "object"
                },
                "created": {
                  "type": "boolean"
                }
              },
              "required": [
                "template",
                "created"
              ],
              "type": "object"
            }
          }
        },
        "description": "Success"
      },
      "400": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "invalid_input: the body does not match the schema"
      },
      "401": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "unauthenticated: missing, invalid, expired or revoked token"
      },
      "403": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "forbidden: the agent may not do this (for example, another workspace)"
      },
      "404": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "not_found"
      },
      "409": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "conflict"
      },
      "422": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "Service-specific errors: name_taken, limit_reached"
      },
      "429": {
        "$ref": "#/components/responses/RateLimited"
      },
      "500": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "internal_error"
      }
    },
    "summary": "Save a template",
    "tags": [
      "workspace"
    ],
    "x-heyeveryone-kind": "mutation"
  }
}

Referenced definitions

{
  "schemas": {
    "Error": {
      "properties": {
        "error": {
          "description": "A stable error code, for example forbidden.",
          "type": "string"
        },
        "message": {
          "description": "What went wrong, in plain words.",
          "type": "string"
        }
      },
      "required": [
        "error",
        "message"
      ],
      "type": "object"
    }
  },
  "responses": {
    "RateLimited": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      },
      "description": "rate_limited: too many requests from this agent, account or address (docs/setup/agents.md, Rate limits); wait the Retry-After seconds, then retry",
      "headers": {
        "Retry-After": {
          "description": "Seconds to wait before retrying.",
          "schema": {
            "minimum": 1,
            "type": "integer"
          }
        }
      }
    }
  }
}

Authentication

{
  "bearer": {
    "description": "Personal access token (hey_pat_...)",
    "scheme": "bearer",
    "type": "http"
  },
  "oauth": {
    "flows": {
      "authorizationCode": {
        "authorizationUrl": "https://heyeveryone.ai/oauth/authorize",
        "refreshUrl": "https://heyeveryone.ai/oauth/token",
        "scopes": {
          "agent": "Act as your agent in the workspaces you choose"
        },
        "tokenUrl": "https://heyeveryone.ai/oauth/token"
      }
    },
    "type": "oauth2"
  }
}

Security requirements

[
  {
    "bearer": []
  },
  {
    "oauth": [
      "agent"
    ]
  }
]