Skip to content

Docs

rewrite_text

Apply one rewrite action to text: `shorten` (to `targetChars` if given), `sharpen_hook` (opening line only), `change_tone` (to `tone`), `fix_grammar`, `rephrase` (fresh words), `punchier` (shorter sentences, stronger verbs), `translate` (into `language`, required) or `thread` (`text` holds the posts separated by a line with only `---`, `posts` lists them, each under `targetChars` if given; pass them to create_post / update_post as segments). Returns the text only; saves nothing. With `proposeFor` it is also stored as a pending suggestion for the original draft or one segment of a channel version, bound to `baseVersion` (checked before charging: `version_conflict`); a post `thread` replaces that segment. A person accepts or rejects it; a rejected one isn't refunded.

Apply one rewrite action to text: shorten (to targetChars if given), sharpen_hook (opening line only), change_tone (to tone), fix_grammar, rephrase (fresh words), punchier (shorter sentences, stronger verbs), translate (into language, required) or thread (text holds the posts separated by a line with only ---, posts lists them, each under targetChars if given; pass them to create_post / update_post as segments). Returns the text only; saves nothing. With proposeFor it is also stored as a pending suggestion for the original draft or one segment of a channel version, bound to baseVersion (checked before charging: version_conflict); a post thread replaces that segment. A person accepts or rejects it; a rejected one isn't refunded.

Uses heyeveryone AI and costs 1 credits (1 credit per rewrite). Tell the person before calling it.

Access and cost

  • Kind: mutation
  • Scope: workspace
  • Actors: member, agent
  • Credits: 1 credit per rewrite.
  • Requires confirmation: false
  • Accepts idempotency key: true

Input schema

{
  "properties": {
    "workspaceId": {
      "format": "uuid",
      "type": "string"
    },
    "text": {
      "maxLength": 5000,
      "minLength": 1,
      "type": "string"
    },
    "action": {
      "enum": [
        "shorten",
        "sharpen_hook",
        "change_tone",
        "fix_grammar",
        "rephrase",
        "punchier",
        "translate",
        "thread"
      ],
      "type": "string"
    },
    "tone": {
      "maxLength": 60,
      "type": "string"
    },
    "targetChars": {
      "maximum": 5000,
      "minimum": 1,
      "type": "integer"
    },
    "language": {
      "maxLength": 40,
      "minLength": 2,
      "type": "string"
    },
    "proposeFor": {
      "oneOf": [
        {
          "properties": {
            "target": {
              "const": "master",
              "type": "string"
            },
            "pieceId": {
              "format": "uuid",
              "type": "string"
            },
            "baseVersion": {
              "minimum": 1,
              "type": "integer"
            }
          },
          "required": [
            "target",
            "pieceId",
            "baseVersion"
          ],
          "type": "object"
        },
        {
          "properties": {
            "target": {
              "const": "post",
              "type": "string"
            },
            "pieceId": {
              "format": "uuid",
              "type": "string"
            },
            "postId": {
              "format": "uuid",
              "type": "string"
            },
            "segmentIndex": {
              "default": 0,
              "minimum": 0,
              "type": "integer"
            },
            "baseVersion": {
              "minimum": 1,
              "type": "integer"
            }
          },
          "required": [
            "target",
            "pieceId",
            "postId",
            "baseVersion"
          ],
          "type": "object"
        }
      ]
    },
    "idempotencyKey": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    }
  },
  "required": [
    "workspaceId",
    "text",
    "action"
  ],
  "type": "object"
}

Output schema

{
  "additionalProperties": false,
  "properties": {
    "text": {
      "type": "string"
    },
    "posts": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ]
    },
    "proposal": {
      "anyOf": [
        {
          "additionalProperties": false,
          "properties": {
            "id": {
              "format": "uuid",
              "type": "string"
            },
            "workspaceId": {
              "format": "uuid",
              "type": "string"
            },
            "pieceId": {
              "anyOf": [
                {
                  "format": "uuid",
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "target": {
              "enum": [
                "master",
                "post",
                "piece"
              ],
              "type": "string"
            },
            "postId": {
              "anyOf": [
                {
                  "format": "uuid",
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "channelAccountId": {
              "anyOf": [
                {
                  "format": "uuid",
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "format": {
              "anyOf": [
                {
                  "pattern": "^[a-z][a-z0-9_]*$",
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "baseVersion": {
              "anyOf": [
                {
                  "minimum": 1,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "content": {
              "additionalProperties": false,
              "properties": {
                "text": {
                  "type": "string"
                },
                "segments": {
                  "items": {
                    "additionalProperties": false,
                    "properties": {
                      "text": {
                        "type": "string"
                      },
                      "media": {
                        "items": {
                          "additionalProperties": false,
                          "properties": {
                            "mediaAssetId": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "altText": {
                              "maxLength": 2000,
                              "type": "string"
                            }
                          },
                          "required": [
                            "mediaAssetId"
                          ],
                          "type": "object"
                        },
                        "type": "array"
                      }
                    },
                    "required": [
                      "text",
                      "media"
                    ],
                    "type": "object"
                  },
                  "type": "array"
                },
                "title": {
                  "type": "string"
                },
                "plannedFor": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "plannedTime": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "campaignLabels": {
                  "items": {
                    "type": "string"
                  },
                  "type": "array"
                },
                "targets": {
                  "items": {
                    "additionalProperties": false,
                    "properties": {
                      "channelAccountId": {
                        "format": "uuid",
                        "type": "string"
                      },
                      "format": {
                        "pattern": "^[a-z][a-z0-9_]*$",
                        "type": "string"
                      }
                    },
                    "required": [
                      "channelAccountId"
                    ],
                    "type": "object"
                  },
                  "type": "array"
                },
                "sources": {
                  "items": {
                    "additionalProperties": false,
                    "properties": {
                      "sourceId": {
                        "format": "uuid",
                        "type": "string"
                      },
                      "mediaAssetId": {
                        "format": "uuid",
                        "type": "string"
                      },
                      "passage": {
                        "additionalProperties": false,
                        "properties": {
                          "start": {
                            "minimum": 0,
                            "type": "number"
                          },
                          "end": {
                            "minimum": 0,
                            "type": "number"
                          },
                          "unit": {
                            "enum": [
                              "chars",
                              "seconds"
                            ],
                            "type": "string"
                          }
                        },
                        "required": [
                          "start",
                          "end"
                        ],
                        "type": "object"
                      }
                    },
                    "type": "object"
                  },
                  "type": "array"
                }
              },
              "type": "object"
            },
            "origin": {
              "enum": [
                "adapt_piece",
                "rewrite_text",
                "agent",
                "member",
                "ai_agent"
              ],
              "type": "string"
            },
            "aiRunId": {
              "anyOf": [
                {
                  "format": "uuid",
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "note": {
              "type": [
                "string",
                "null"
              ]
            },
            "creditsSpent": {
              "minimum": 0,
              "type": "integer"
            },
            "status": {
              "enum": [
                "pending",
                "accepted",
                "rejected"
              ],
              "type": "string"
            },
            "stale": {
              "type": "boolean"
            },
            "staleReason": {
              "type": [
                "string",
                "null"
              ]
            },
            "currentVersion": {
              "anyOf": [
                {
                  "minimum": 1,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "author": {
              "additionalProperties": false,
              "properties": {
                "kind": {
                  "enum": [
                    "member",
                    "guest",
                    "agent",
                    "system"
                  ],
                  "type": "string"
                },
                "accountId": {
                  "anyOf": [
                    {
                      "format": "uuid",
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "agentClientId": {
                  "anyOf": [
                    {
                      "format": "uuid",
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "guestId": {
                  "anyOf": [
                    {
                      "format": "uuid",
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "kind",
                "accountId",
                "agentClientId",
                "guestId",
                "name"
              ],
              "type": "object"
            },
            "decidedBy": {
              "anyOf": [
                {
                  "additionalProperties": false,
                  "properties": {
                    "kind": {
                      "enum": [
                        "member",
                        "guest",
                        "agent",
                        "system"
                      ],
                      "type": "string"
                    },
                    "accountId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "agentClientId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "guestId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "kind",
                    "accountId",
                    "agentClientId",
                    "guestId",
                    "name"
                  ],
                  "type": "object"
                },
                {
                  "type": "null"
                }
              ]
            },
            "decidedAt": {
              "anyOf": [
                {
                  "format": "date-time",
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "decisionNote": {
              "type": [
                "string",
                "null"
              ]
            },
            "resultVersion": {
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "resultPieceId": {
              "anyOf": [
                {
                  "format": "uuid",
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "createdAt": {
              "format": "date-time",
              "type": "string"
            }
          },
          "required": [
            "id",
            "workspaceId",
            "pieceId",
            "target",
            "postId",
            "channelAccountId",
            "format",
            "baseVersion",
            "content",
            "origin",
            "aiRunId",
            "note",
            "creditsSpent",
            "status",
            "stale",
            "staleReason",
            "currentVersion",
            "author",
            "decidedBy",
            "decidedAt",
            "decisionNote",
            "resultVersion",
            "resultPieceId",
            "createdAt"
          ],
          "type": "object"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "text",
    "posts",
    "proposal"
  ],
  "type": "object"
}

Errors

[
  "ai_generation_failed",
  "insufficient_credits",
  "plan_limit_reached",
  "idempotency_conflict",
  "version_conflict",
  "post_locked"
]

Annotations

{
  "destructiveHint": false,
  "idempotentHint": false,
  "openWorldHint": false,
  "readOnlyHint": false,
  "title": "Rewrite text"
}