> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getoneprofile.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Keep the rewrite and the lesson that wrote it

> The agent's instructions take the lesson (its next version), and the rewrite becomes the noted contact's thread, marked Looks good, so it is what sends. Every thread of the sequence already marked Looks good keeps its words across the new version. The run stays open on the new version; threads written ahead under the old instructions that nobody read leave it, and are written again when opened. A rewrite is kept whole: slot_keys, when sent, must name every change. Repeating the call is a no-op.



## OpenAPI

````yaml /openapi.json post /sequences/{sequence_id}/agent/training/{session_id}/apply/
openapi: 3.1.0
info:
  contact:
    email: support@getoneprofile.ai
    name: Oneprofile Support
  description: >-
    REST API reference for Oneprofile, the GTM data layer for your CRM. Manage
    tables, enrichments, and integrations. Authenticate with an API key to get
    started.
  termsOfService: https://www.getoneprofile.ai/terms
  title: API Reference | Oneprofile
  version: '0.0'
servers:
  - url: https://api.getoneprofile.ai
security: []
tags:
  - description: >-
      The docked AI Assistant: its general chat about the workspace and the
      product, streamed as Server-Sent Events, and the one list of a person's
      threads across every assistant, with pin, rename, delete and the
      search-to-table link.
    name: assistant
  - description: >-
      The messages a person keeps to send the assistant again: the ones the
      workspace saved and the ones that ship with the product, with save,
      rename, edit and delete.
    name: assistant-prompt
  - description: >-
      Granted workspace actions: what the AI Assistant proposed or applied in a
      conversation, the approve and dismiss decisions on each card, the
      workspace's approval threshold and default grants, and the eight verbs.
    name: workspace-actions
  - description: >-
      The Getting started checklist: a workspace's progress through the six
      steps from its first people search to its first launched sequence.
    name: onboarding
  - description: Senders, connected mailboxes, tags, and the Google connect flow.
    name: senders
  - description: The workspace do-not-contact list, enforced before every send.
    name: suppression
  - description: >-
      The workspace's recontact rule: how long before anyone hears from us
      again.
    name: contact_cooldown
  - description: 'Sequence authoring: the graph, the table-backed audience, previews.'
    name: sequences
  - description: >-
      The outbound agent behind a sequence: the voice it writes in, its
      per-message prompts, what it wrote and what people told it.
    name: outbound-agents
  - description: >-
      The LinkedIn channel: connecting an account to a sender, its safety limits
      and history, and the protocol the browser extension speaks.
    name: linkedin
  - description: >-
      The approval queue: everything waiting on a person across every sender and
      channel, and the workspace's manual or automatic modes per channel.
    name: outreach
  - description: 'The unified outreach inbox: threads, replies, labels, events.'
    name: inbox
  - description: 'The AI reply layer: workspace settings, drafts, and approval.'
    name: inbox-ai
  - description: Notification rules, per-user preferences, and the Slack connection.
    name: notifications
  - description: Endpoints for seeing all available integration types.
    name: integration-types
  - description: Endpoints for creating and managing integrations.
    name: integrations
  - description: Endpoints for the generic OAuth install/claim app-listings engine.
    name: app-listings
  - description: Endpoints for creating and managing API keys.
    name: apikey
  - description: >-
      The Model Context Protocol endpoint: use Oneprofile from Claude Code,
      Claude Desktop, Cursor or any other MCP client, with an API key as the
      bearer token.
    name: mcp
  - description: Endpoints for managing billing and subscription information.
    name: billing
  - description: Endpoints for creating and managing tables.
    name: tables
  - description: Endpoints for table columns, formula previews, and on-demand column runs.
    name: table-columns
  - description: Endpoints for table rows and manual cell edits.
    name: table-rows
  - description: Endpoints for observing and cancelling table recompute runs.
    name: table-runs
  - description: >-
      Endpoints for org-shared per-column display preferences: hidden, pinned,
      width, and colour tint.
    name: table-ui-prefs
  - description: >-
      Endpoints for the org-shared names given to the column tint palette: what
      this organisation calls each colour. Org-level, not per-table.
    name: table-column-color-labels
  - description: >-
      Endpoints for the enrichment action catalog, model list, presets, draft
      generation, and saved agents.
    name: table-enrichments
  - description: >-
      Endpoints for teaching a saved agent from example rows: training sessions,
      per-row feedback, and the proposed prompt to approve.
    name: agent-training
  - description: >-
      The durable audit trail of a table's enrichment actions: configured,
      edited, run, cancelled, and settled cost.
    name: table-enrichment-audit-logs
  - description: Endpoints for saving and applying column templates.
    name: table-templates
  - description: Server-sent change feed for a table's grid.
    name: table-events
  - description: 'Endpoints for org-shared saved table views: sort, filters, hidden columns.'
    name: table-views
  - description: >-
      Endpoints for PER-USER table preferences: favourites and recently opened.
      Unlike the rest of the table surface these are personal, so two members of
      one organisation legitimately see different answers.
    name: table-user-prefs
  - description: >-
      Endpoints for building a table from an uploaded CSV: upload and preview
      the inferred columns, commit the reviewed mapping, then poll the row load.
    name: table-imports
  - description: Endpoint for downloading a table's rows as CSV.
    name: table-export
  - description: >-
      Endpoints for the integration a table imports from: attach and preview it,
      promote imported fields into columns, and run the import on demand.
    name: table-sources
  - description: >-
      Endpoints for a table's recurring import cadence: set it, pause it, and
      read the next fire times.
    name: table-schedules
  - description: >-
      Endpoints for pushing a table's rows out to a connected integration: list
      writable destinations, derive their write capabilities, and map export
      columns.
    name: table-writeback
  - description: >-
      Endpoints backing a lookup column's setup: the connections whose records a
      column could read, and the identity fields one record type can be looked
      up by.
    name: table-integration-lookup
  - description: >-
      Endpoints for sourcing leads from the lead database: count and preview
      matches, land them in a table, and keep saved searches. Alongside people
      and company searches, leads can be sourced from buying signals (what a
      company or person just did), with a catalogue endpoint behind the picker
      that builds them.
    name: find-leads
  - description: >-
      Endpoints for discovering a domain's subdomains from public certificate
      logs and landing the results in a table.
    name: find-subdomains
  - description: Endpoints for the credit balance meter and usage reporting.
    name: credits
  - description: >-
      Endpoints for the workspace referral program: the shareable link, the
      friends who joined through it, and claiming a code after signup.
    name: referral
  - description: >-
      Endpoints for the affiliate program's own dashboard: enrolling and
      claiming a code, the summary, stats and activity feed, the commission
      ledger, and identity verification and payouts.
    name: affiliate
  - description: >-
      Endpoints for the design partner program's customer surface: whether this
      workspace is a design partner, the badges its feedback has earned, and
      sending and reading that feedback.
    name: design-partner
  - description: >-
      Endpoints for the org-level AI business context (company description,
      ideal customer profile, buyer personas, interest signals and social
      proof), plus domain-based generation and the reference documents whose
      summaries ride alongside those fields.
    name: ai-context
  - description: >-
      Endpoints for the signed-in user's Google Drive connection: starting and
      finishing the OAuth grant, checking or dropping it, and minting the
      short-lived token the Google Picker needs.
    name: google-drive
paths:
  /sequences/{sequence_id}/agent/training/{session_id}/apply/:
    post:
      tags:
        - sequences
      summary: Keep the rewrite and the lesson that wrote it
      description: >-
        The agent's instructions take the lesson (its next version), and the
        rewrite becomes the noted contact's thread, marked Looks good, so it is
        what sends. Every thread of the sequence already marked Looks good keeps
        its words across the new version. The run stays open on the new version;
        threads written ahead under the old instructions that nobody read leave
        it, and are written again when opened. A rewrite is kept whole:
        slot_keys, when sent, must name every change. Repeating the call is a
        no-op.
      operationId: apply_sequence_training
      parameters:
        - in: path
          name: sequence_id
          required: true
          schema:
            format: uuid
            title: Sequence Id
            type: string
        - in: path
          name: session_id
          required: true
          schema:
            format: uuid
            title: Session Id
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SequenceTrainingApplySchema'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SequenceTrainingReadSchema'
          description: Successful Response
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenResponse'
          description: Forbidden
        '404':
          description: Sequence, audience contact, or session not found
        '409':
          description: Sequence, agent, or training revision changed
        '422':
          description: Invalid selection, feedback, or training action
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServerErrorResponse'
          description: Internal server error.
        '502':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServerErrorResponse'
          description: Bad gateway error.
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServerErrorResponse'
          description: Service unavailable.
      security:
        - APIKeyHeader: []
        - HTTPBearer: []
components:
  schemas:
    SequenceTrainingApplySchema:
      description: >-
        Which of the proposed changes to take, and whether to draft again with
        them.
      properties:
        expected_revision:
          minimum: 1
          title: Expected Revision
          type: integer
        rewrite:
          default: false
          title: Rewrite
          type: boolean
        slot_keys:
          anyOf:
            - items:
                type: string
              maxItems: 100
              type: array
            - type: 'null'
          title: Slot Keys
      required:
        - expected_revision
      title: SequenceTrainingApplySchema
      type: object
    SequenceTrainingReadSchema:
      properties:
        agent_id:
          format: uuid
          title: Agent Id
          type: string
        applied_version:
          anyOf:
            - type: integer
            - type: 'null'
          title: Applied Version
        base_version:
          title: Base Version
          type: integer
        contacts:
          items:
            $ref: '#/components/schemas/SequenceTrainingContactReadSchema'
          title: Contacts
          type: array
        created_at:
          format: date-time
          title: Created At
          type: string
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
        id:
          format: uuid
          title: Id
          type: string
        note_waiting:
          default: false
          description: >-
            A note was given while another contact was being written: its
            rewrite is worked out as soon as that write lands.
          title: Note Waiting
          type: boolean
        progress:
          $ref: '#/components/schemas/SequenceTrainingProgressSchema'
        proposal:
          anyOf:
            - $ref: '#/components/schemas/ContactTrainingProposal'
            - type: 'null'
        reviewed_ids:
          description: >-
            Every contact given Looks good or a note in this run, including ones
            that left the run to make room.
          items:
            format: uuid
            type: string
          title: Reviewed Ids
          type: array
        revision:
          title: Revision
          type: integer
        status:
          $ref: '#/components/schemas/ContactTrainingStatus'
        steps:
          items:
            $ref: '#/components/schemas/AiStep'
          title: Steps
          type: array
      required:
        - id
        - agent_id
        - status
        - revision
        - base_version
        - contacts
        - proposal
        - error
        - applied_version
        - created_at
        - progress
      title: SequenceTrainingReadSchema
      type: object
    UnauthorizedResponse:
      properties:
        detail:
          description: The detail of why the request is unauthorized.
          title: Detail
          type: string
      required:
        - detail
      title: UnauthorizedResponse
      type: object
    ForbiddenResponse:
      properties:
        detail:
          description: The detail of why the request is forbidden.
          title: Detail
          type: string
      required:
        - detail
      title: ForbiddenResponse
      type: object
    ServerErrorResponse:
      properties:
        detail:
          description: The detail of why the server returned an error.
          title: Detail
          type: string
      required:
        - detail
      title: ServerErrorResponse
      type: object
    SequenceTrainingContactReadSchema:
      properties:
        context:
          additionalProperties:
            type: string
          title: Context
          type: object
        fields:
          description: >-
            The contact's own columns as the run froze them, read the way the
            approval queue lists a contact: each fact once, a whole-record
            column opened into its facts.
          items:
            $ref: '#/components/schemas/SequenceTrainingContactFieldSchema'
          title: Fields
          type: array
        label:
          title: Label
          type: string
        messages:
          items:
            $ref: '#/components/schemas/SequenceTrainingMessageReadSchema'
          title: Messages
          type: array
        note:
          title: Note
          type: string
        notes:
          description: Every note given on this thread, oldest first.
          items:
            $ref: '#/components/schemas/SequenceTrainingNoteReadSchema'
          title: Notes
          type: array
        notice:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            The agent's answer to a note that needed no change to its
            instructions, in its own sentence: usually a note about this
            contact's own facts.
          title: Notice
        profile_mismatch:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            What the contact's LinkedIn profile says that their row does not,
            usually a job change the row has not caught up with, as one
            sentence: 'LinkedIn says Operations Leader at Chamber Media; the row
            says Sealed.' Null when they agree or no profile was read.
          title: Profile Mismatch
        record_id:
          format: uuid
          title: Record Id
          type: string
        verdict:
          anyOf:
            - $ref: '#/components/schemas/ContactReviewVerdict'
            - type: 'null'
      required:
        - record_id
        - label
        - context
        - fields
        - messages
        - verdict
        - note
      title: SequenceTrainingContactReadSchema
      type: object
    SequenceTrainingProgressSchema:
      description: How training on this sequence is going, counted across the run.
      properties:
        fixed:
          description: Lessons kept in this run.
          title: Fixed
          type: integer
        in_a_row:
          description: Contacts given Looks good, with no note, since the last note.
          title: In A Row
          type: integer
        lessons:
          description: Each lesson kept, in the agent's own sentence, oldest first.
          items:
            type: string
          title: Lessons
          type: array
        ready:
          description: Whether in_a_row has reached ready_after.
          title: Ready
          type: boolean
        ready_after:
          description: How many in a row make the agent ready to send on its own.
          title: Ready After
          type: integer
        reviewed:
          description: Contacts given Looks good or a note in this run.
          title: Reviewed
          type: integer
      required:
        - reviewed
        - fixed
        - in_a_row
        - ready_after
        - ready
        - lessons
      title: SequenceTrainingProgressSchema
      type: object
    ContactTrainingProposal:
      description: The session's candidate prompt update, kept pending until applied.
      properties:
        changes:
          items:
            $ref: '#/components/schemas/ContactPromptChange'
          title: Changes
          type: array
        made_at:
          default: 0
          title: Made At
          type: integer
        record_id:
          anyOf:
            - format: uuid
              type: string
            - type: 'null'
          title: Record Id
        round_ids:
          items:
            format: uuid
            type: string
          title: Round Ids
          type: array
        summary:
          title: Summary
          type: string
      required:
        - summary
      title: ContactTrainingProposal
      type: object
    ContactTrainingStatus:
      description: A session's phase, also used to resume its review screen.
      enum:
        - running
        - reviewing
        - proposing
        - proposed
        - completed
        - abandoned
      title: ContactTrainingStatus
      type: string
    AiStep:
      additionalProperties: false
      description: >-
        One thing an AI turn did, as the wire spells it.


        Field-for-field identical to
        ``table_live_updates.TableCellActivityStepSchema``

        ON PURPOSE, and the duplication is the design. That schema sits in the
        table

        stratum's kernel, which the lead search, inbox and sequence surfaces
        have no

        business importing; this one sits under every surface equally. Because
        the

        two agree exactly, the frontend's ``TimelineStep`` renders both with no

        conversion and no second component, which is the property worth
        protecting.

        ``test_ai_step_mirrors_the_cell_activity_step`` pins them together.


        Plain strings rather than enums, for the same reason the cell schema
        uses

        them: the vocabulary is open, clients must tolerate tokens they have not

        learned yet, and a new action should never be able to break a running

        dashboard.
      properties:
        action:
          description: >-
            What kind of move this was, e.g. `read_table`, `plan`,
            `write_column`.
          title: Action
          type: string
        detail:
          default: ''
          description: >-
            The step's input: the instruction, the column it read, the query it
            ran.
          title: Detail
          type: string
        duration_ms:
          anyOf:
            - type: integer
            - type: 'null'
          description: Wall clock for the work this step describes, never an estimate.
          title: Duration Ms
        observation:
          default: ''
          description: >-
            One line on what came back. The half that makes a step worth
            reading.
          maxLength: 500
          title: Observation
          type: string
        outcome:
          default: completed
          description: >-
            `completed`, `failed`, `refused` or `stopped`. Clients must tolerate
            new tokens.
          title: Outcome
          type: string
        thought:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            The model's stated reasoning for choosing this step. Set by the
            agent loop; the assistant surfaces leave it null, and the renderer
            simply omits the rung.
          title: Thought
      required:
        - action
      title: AiStep
      type: object
    SequenceTrainingContactFieldSchema:
      properties:
        name:
          title: Name
          type: string
        value:
          title: Value
          type: string
      required:
        - name
        - value
      title: SequenceTrainingContactFieldSchema
      type: object
    SequenceTrainingMessageReadSchema:
      properties:
        authored:
          title: Authored
          type: boolean
        body:
          anyOf:
            - type: string
            - type: 'null'
          title: Body
        conditional:
          anyOf:
            - type: string
            - type: 'null'
          title: Conditional
        edited_body:
          anyOf:
            - type: string
            - type: 'null'
          title: Edited Body
        edited_subject:
          anyOf:
            - type: string
            - type: 'null'
          title: Edited Subject
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
        facts_used:
          items:
            type: string
          title: Facts Used
          type: array
        id:
          format: uuid
          title: Id
          type: string
        kind:
          title: Kind
          type: string
        note:
          title: Note
          type: string
        previous_body:
          anyOf:
            - type: string
            - type: 'null'
          title: Previous Body
        previous_subject:
          anyOf:
            - type: string
            - type: 'null'
          title: Previous Subject
        proposed_body:
          anyOf:
            - type: string
            - type: 'null'
          description: The words the rewrite waiting on this contact wrote.
          title: Proposed Body
        proposed_error:
          anyOf:
            - type: string
            - type: 'null'
          description: Why the rewrite could not write this message.
          title: Proposed Error
        proposed_send:
          anyOf:
            - $ref: '#/components/schemas/SequenceTrainingSendSchema'
            - type: 'null'
          description: The rewrite's words, read as ``send`` reads the words shown.
        proposed_subject:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            The subject the rewrite waiting on this contact wrote, when it has
            one: what the agent will write once the rewrite is kept.
          title: Proposed Subject
        reasoning:
          anyOf:
            - type: string
            - type: 'null'
          title: Reasoning
        reply_to_step_id:
          anyOf:
            - format: uuid
              type: string
            - type: 'null'
          description: >-
            The step whose thread this message replies in, or null when it opens
            a thread of its own.
          title: Reply To Step Id
        send:
          anyOf:
            - $ref: '#/components/schemas/SequenceTrainingSendSchema'
            - type: 'null'
          description: >-
            Whether the agent's words would send on their own or wait for
            approval, under the sequence's settings as they stand. Null for a
            message a person typed, one not written, or when nothing would send
            it (no sender, no LinkedIn account).
        steps:
          items:
            $ref: '#/components/schemas/AiStep'
          title: Steps
          type: array
        subject:
          anyOf:
            - type: string
            - type: 'null'
          title: Subject
        timing:
          title: Timing
          type: string
        title:
          title: Title
          type: string
      required:
        - id
        - title
        - timing
        - kind
        - authored
        - conditional
        - subject
        - body
        - error
        - note
        - edited_subject
        - edited_body
        - previous_subject
        - previous_body
        - reasoning
        - facts_used
        - steps
        - reply_to_step_id
      title: SequenceTrainingMessageReadSchema
      type: object
    SequenceTrainingNoteReadSchema:
      description: One note given on a contact's thread, and where it stands.
      properties:
        note:
          title: Note
          type: string
        state:
          $ref: '#/components/schemas/FeedbackRoundState'
          description: >-
            `pending` its rewrite is being worked out or waits to be kept;
            `applied` kept, so the agent learned it; `discarded` its rewrite was
            discarded; `settled` the agent answered that nothing needed to
            change, or a verdict was given instead.
      required:
        - note
        - state
      title: SequenceTrainingNoteReadSchema
      type: object
    ContactReviewVerdict:
      description: Only an explicit review counts as feedback.
      enum:
        - good
        - bad
        - skipped
      title: ContactReviewVerdict
      type: string
    ContactPromptChange:
      description: A coordinated change to one existing prompt slot.
      properties:
        current:
          title: Current
          type: string
        proposed:
          title: Proposed
          type: string
        rationale:
          title: Rationale
          type: string
        slot_key:
          title: Slot Key
          type: string
      required:
        - slot_key
        - current
        - proposed
        - rationale
      title: ContactPromptChange
      type: object
    SequenceTrainingSendSchema:
      description: >-
        Whether a message would leave on its own when its turn comes, and if
        not, why.
      properties:
        alone:
          description: >-
            True when the send would let these words go without a person; false
            when they would wait for approval in Tasks.
          title: Alone
          type: boolean
        doubt:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            When the words themselves hold the message (the agent was not
            confident, knew too little, or a check found something): one
            sentence saying what. Null otherwise.
          title: Doubt
        reason:
          anyOf:
            - $ref: '#/components/schemas/AskReason'
            - type: 'null'
          description: >-
            Why they would wait, in the approval queue's own reasons; null when
            alone.
      required:
        - alone
        - reason
      title: SequenceTrainingSendSchema
      type: object
    FeedbackRoundState:
      description: >-
        Where one note stands: being answered, learned, thrown away, or answered
        with no change.
      enum:
        - pending
        - applied
        - discarded
        - settled
      title: FeedbackRoundState
      type: string
    AskReason:
      description: >-
        Why a message that could have sent unattended was put in front of a
        person.


        One vocabulary for every gate between an agent writing a message and the

        message leaving: what the agent itself said about the draft

        (``LOW_CONFIDENCE``, ``FINDINGS``, ``INSUFFICIENT_DATA``, ``POLICY``),
        what

        the sender or the cadence asked for (``ALWAYS_ASK``,
        ``SEQUENCE_MANUAL``,

        ``STEP_REQUIRES_APPROVAL``), what the pacing rules refused

        (``DAILY_CAP``, ``CONSECUTIVE_CAP``, ``THREAD_CAP``, ``HOURLY_CAP``,

        ``ORG_DAILY_CAP``), what the mailbox or the thread made unsafe

        (``UNVERIFIED_SENDER``, ``DIFFERENT_SENDER``, ``LABEL``,
        ``STALE_INBOUND``,

        ``SEQUENCE_GONE``), and what the counterparty turned out to be

        (``BOT_QUESTION``, ``AUTOMATED_COUNTERPARTY``, ``AUTHENTICATION``,

        ``LANGUAGE``, ``LINKEDIN_ONLY``). ``KILL_SWITCH`` is the platform switch

        that stops unattended sending outright, and ``SEND_INTERRUPTED`` an

        unattended reply whose send never got as far as a provider.

        ``SENDER_SWITCHED_TO_MANUAL`` is a LinkedIn step queued unasked that
        went

        back to a person because its sender switched to manual before it ran.


        Stored on the task so the queue can say why each row is there, and so

        "why did nothing send" is answerable by counting rows rather than by

        reading logs.
      enum:
        - low_confidence
        - findings
        - insufficient_data
        - policy
        - always_ask
        - sequence_manual
        - step_requires_approval
        - daily_cap
        - unverified_sender
        - suppressed
        - different_sender
        - label
        - consecutive_cap
        - thread_cap
        - hourly_cap
        - org_daily_cap
        - stale_inbound
        - sequence_gone
        - bot_question
        - automated_counterparty
        - kill_switch
        - authentication
        - language
        - linkedin_only
        - send_interrupted
        - sender_switched_to_manual
      title: AskReason
      type: string
  securitySchemes:
    APIKeyHeader:
      in: header
      name: X-API-Key
      type: apiKey
    HTTPBearer:
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.