## Publish a sequence draft

`client.Sequence.PublishDraft(ctx, id, body) (*SequencePublishDraftResponse, error)`

**post** `/v1/sequences/{id}/draft/publish`

Publishes the open draft at `expectedVersion` and returns the sequence. A first publish leaves the sequence `DEACTIVATED`; activate it to start sending. Contacts already enrolled continue on the new version.

A refused publish changes nothing. Returns 400 `invalid_configuration` with the problems under `issues`, 400 `permissions_not_granted` or `no_selectable_sender` when the steps cannot send yet, 404 `draft_not_found` when no draft is open, and 409 when `expectedVersion` is not the open draft’s `version`; retrieve the draft and retry. See <u>[Sequence errors](/using-the-api/errors/#sequence-errors)</u> for what each code means and how to resolve it.

**[Required scope](/using-the-api/scopes/):** `sequences:update`

**[Rate limit category](/using-the-api/rate-limits/):** Write

### Parameters

- `id string`

  Unique identifier of the sequence.

- `body SequencePublishDraftParams`

  - `ExpectedVersion param.Field[string]`

    The open draft’s `version` as last read.

### Returns

- `type SequencePublishDraftResponse struct{…}`

  - `ID string`

    Unique identifier of the sequence.

  - `Channels []string`

    Channels the published steps send on; empty before the first publish.

    - `const SequencePublishDraftResponseChannelEmail SequencePublishDraftResponseChannel = "EMAIL"`

    - `const SequencePublishDraftResponseChannelLinkedin SequencePublishDraftResponseChannel = "LINKEDIN"`

  - `CreatedAt string`

    ISO 8601 creation timestamp.

  - `Definition SequencePublishDraftResponseDefinition`

    Published configuration, or null before the first publish.

    - `Description string`

      What this version of the sequence is for.

    - `Messaging SequencePublishDraftResponseDefinitionMessaging`

      Messaging inputs that frame every step.

      - `CallToAction string`

        What the recipient is asked to do.

      - `Persona string`

        Who the sequence targets.

      - `Trigger string`

        Why the outreach is timely.

      - `ValueProp string`

        The value proposition.

    - `Pacing SequencePublishDraftResponseDefinitionPacing`

      How the whole sequence paces each step type it sends, keyed by sequence step type.

      - `Email SequencePublishDraftResponseDefinitionPacingEmail`

        Email steps.

        - `DailyLimit int64`

          Most sends of this step type across the whole sequence in any rolling 24 hours, or null when the sequence sets no daily cap. Workspace and sender limits still apply.

      - `LinkedinInvite SequencePublishDraftResponseDefinitionPacingLinkedinInvite`

        LinkedIn connection requests.

        - `DailyLimit int64`

          Most sends of this step type across the whole sequence in any rolling 24 hours, or null when the sequence sets no daily cap. Workspace and sender limits still apply.

      - `LinkedinMessage SequencePublishDraftResponseDefinitionPacingLinkedinMessage`

        LinkedIn messages.

        - `DailyLimit int64`

          Most sends of this step type across the whole sequence in any rolling 24 hours, or null when the sequence sets no daily cap. Workspace and sender limits still apply.

    - `Priority string`

      Send priority relative to other sequences.

      - `const SequencePublishDraftResponseDefinitionPriorityHigh SequencePublishDraftResponseDefinitionPriority = "HIGH"`

      - `const SequencePublishDraftResponseDefinitionPriorityNormal SequencePublishDraftResponseDefinitionPriority = "NORMAL"`

    - `SendWindow SequencePublishDraftResponseDefinitionSendWindow`

      When the sequence may send.

      - `DaysOfWeek []int64`

        Days sends may go out, 0 = Sunday.

      - `EndHour int64`

        Local hour sends stop, exclusive (1–24).

      - `StartHour int64`

        First local hour sends may go out (0–23).

      - `Timezone string`

        IANA timezone of the window.

    - `Steps []SequencePublishDraftResponseDefinitionStepUnion`

      Email, LinkedIn and wait steps in execution order.

      - `type SequencePublishDraftResponseDefinitionStepObject struct{…}`

        - `ID string`

          Step identifier, referenced by enrollment `currentStepId` and message `sequenceStepId`.

        - `DeliveryMode string`

          `AUTO` sends without manual approval, subject to the send window and limits; `FOR_REVIEW` requires a person to approve the draft before sending.

          - `const SequencePublishDraftResponseDefinitionStepObjectDeliveryModeAuto SequencePublishDraftResponseDefinitionStepObjectDeliveryMode = "AUTO"`

          - `const SequencePublishDraftResponseDefinitionStepObjectDeliveryModeForReview SequencePublishDraftResponseDefinitionStepObjectDeliveryMode = "FOR_REVIEW"`

        - `Mode string`

          How each message is written: `AGENT` composes it from `prompt`; `TEMPLATE` sends `template` to every contact, with its variables filled in.

          - `const SequencePublishDraftResponseDefinitionStepObjectModeAgent SequencePublishDraftResponseDefinitionStepObjectMode = "AGENT"`

        - `Name string`

          Display name of the step.

        - `Prompt string`

          Instructions the agent follows when composing this message.

        - `Type string`

          Step type.

          - `const SequencePublishDraftResponseDefinitionStepObjectTypeEmail SequencePublishDraftResponseDefinitionStepObjectType = "EMAIL"`

          - `const SequencePublishDraftResponseDefinitionStepObjectTypeLinkedinMessage SequencePublishDraftResponseDefinitionStepObjectType = "LINKEDIN_MESSAGE"`

      - `type SequencePublishDraftResponseDefinitionStepObject2 struct{…}`

        - `ID string`

          Step identifier, referenced by enrollment `currentStepId` and message `sequenceStepId`.

        - `DeliveryMode string`

          `AUTO` sends without manual approval, subject to the send window and limits; `FOR_REVIEW` requires a person to approve the draft before sending.

          - `const SequencePublishDraftResponseDefinitionStepObject2DeliveryModeAuto SequencePublishDraftResponseDefinitionStepObject2DeliveryMode = "AUTO"`

          - `const SequencePublishDraftResponseDefinitionStepObject2DeliveryModeForReview SequencePublishDraftResponseDefinitionStepObject2DeliveryMode = "FOR_REVIEW"`

        - `IncludeNote bool`

          Whether the connection request carries a note. A step authored before this setting existed reads as true.

        - `Mode string`

          How each message is written: `AGENT` composes it from `prompt`; `TEMPLATE` sends `template` to every contact, with its variables filled in.

          - `const SequencePublishDraftResponseDefinitionStepObject2ModeAgent SequencePublishDraftResponseDefinitionStepObject2Mode = "AGENT"`

        - `Name string`

          Display name of the step.

        - `Prompt string`

          Instructions the agent follows when composing this message.

        - `Type string`

          Step type.

          - `const SequencePublishDraftResponseDefinitionStepObject2TypeLinkedinInvite SequencePublishDraftResponseDefinitionStepObject2Type = "LINKEDIN_INVITE"`

      - `type SequencePublishDraftResponseDefinitionStepObject3 struct{…}`

        - `ID string`

          Step identifier, referenced by enrollment `currentStepId` and message `sequenceStepId`.

        - `DeliveryMode string`

          `AUTO` sends without manual approval, subject to the send window and limits; `FOR_REVIEW` requires a person to approve the draft before sending.

          - `const SequencePublishDraftResponseDefinitionStepObject3DeliveryModeAuto SequencePublishDraftResponseDefinitionStepObject3DeliveryMode = "AUTO"`

          - `const SequencePublishDraftResponseDefinitionStepObject3DeliveryModeForReview SequencePublishDraftResponseDefinitionStepObject3DeliveryMode = "FOR_REVIEW"`

        - `Mode string`

          How each message is written: `AGENT` composes it from `prompt`; `TEMPLATE` sends `template` to every contact, with its variables filled in.

          - `const SequencePublishDraftResponseDefinitionStepObject3ModeTemplate SequencePublishDraftResponseDefinitionStepObject3Mode = "TEMPLATE"`

        - `Name string`

          Display name of the step.

        - `Template SequencePublishDraftResponseDefinitionStepObject3Template`

          The email every contact receives.

          - `Body string`

            Email body as Markdown, without the sign-off or signature, which are added when the message is written. Each `{{ }}` is a variable filled in per contact, with a fallback for a contact missing the value; a field variable names the field by the `ad_` ID the field-definitions endpoints list.

          - `Subject string`

            Plain-text subject line. Each `{{ }}` is a variable filled in per contact, with a fallback for a contact missing the value; a field variable names the field by the `ad_` ID the field-definitions endpoints list.

        - `Type string`

          Step type.

          - `const SequencePublishDraftResponseDefinitionStepObject3TypeEmail SequencePublishDraftResponseDefinitionStepObject3Type = "EMAIL"`

      - `type SequencePublishDraftResponseDefinitionStepObject4 struct{…}`

        - `ID string`

          Step identifier, referenced by enrollment `currentStepId` and message `sequenceStepId`.

        - `DeliveryMode string`

          `AUTO` sends without manual approval, subject to the send window and limits; `FOR_REVIEW` requires a person to approve the draft before sending.

          - `const SequencePublishDraftResponseDefinitionStepObject4DeliveryModeAuto SequencePublishDraftResponseDefinitionStepObject4DeliveryMode = "AUTO"`

          - `const SequencePublishDraftResponseDefinitionStepObject4DeliveryModeForReview SequencePublishDraftResponseDefinitionStepObject4DeliveryMode = "FOR_REVIEW"`

        - `Mode string`

          How each message is written: `AGENT` composes it from `prompt`; `TEMPLATE` sends `template` to every contact, with its variables filled in.

          - `const SequencePublishDraftResponseDefinitionStepObject4ModeTemplate SequencePublishDraftResponseDefinitionStepObject4Mode = "TEMPLATE"`

        - `Name string`

          Display name of the step.

        - `Template SequencePublishDraftResponseDefinitionStepObject4Template`

          The message every contact receives; for an invite, its connection note, sent only with `includeNote`.

          - `Body string`

            Plain-text message. Each `{{ }}` is a variable filled in per contact, with a fallback for a contact missing the value; a field variable names the field by the `ad_` ID the field-definitions endpoints list.

        - `Type string`

          Step type.

          - `const SequencePublishDraftResponseDefinitionStepObject4TypeLinkedinMessage SequencePublishDraftResponseDefinitionStepObject4Type = "LINKEDIN_MESSAGE"`

      - `type SequencePublishDraftResponseDefinitionStepObject5 struct{…}`

        - `ID string`

          Step identifier, referenced by enrollment `currentStepId` and message `sequenceStepId`.

        - `DeliveryMode string`

          `AUTO` sends without manual approval, subject to the send window and limits; `FOR_REVIEW` requires a person to approve the draft before sending.

          - `const SequencePublishDraftResponseDefinitionStepObject5DeliveryModeAuto SequencePublishDraftResponseDefinitionStepObject5DeliveryMode = "AUTO"`

          - `const SequencePublishDraftResponseDefinitionStepObject5DeliveryModeForReview SequencePublishDraftResponseDefinitionStepObject5DeliveryMode = "FOR_REVIEW"`

        - `IncludeNote bool`

          Whether the connection request carries a note. A step authored before this setting existed reads as true.

        - `Mode string`

          How each message is written: `AGENT` composes it from `prompt`; `TEMPLATE` sends `template` to every contact, with its variables filled in.

          - `const SequencePublishDraftResponseDefinitionStepObject5ModeTemplate SequencePublishDraftResponseDefinitionStepObject5Mode = "TEMPLATE"`

        - `Name string`

          Display name of the step.

        - `Template SequencePublishDraftResponseDefinitionStepObject5Template`

          The message every contact receives; for an invite, its connection note, sent only with `includeNote`.

          - `Body string`

            Plain-text message. Each `{{ }}` is a variable filled in per contact, with a fallback for a contact missing the value; a field variable names the field by the `ad_` ID the field-definitions endpoints list.

        - `Type string`

          Step type.

          - `const SequencePublishDraftResponseDefinitionStepObject5TypeLinkedinInvite SequencePublishDraftResponseDefinitionStepObject5Type = "LINKEDIN_INVITE"`

      - `type SequencePublishDraftResponseDefinitionStepObject6 struct{…}`

        - `ID string`

          Step identifier.

        - `Duration int64`

          Length of the wait.

        - `Type string`

          `WAIT` pauses for a fixed time; `WAIT_FOR_CONNECTION` waits up to that long for a LinkedIn invite to be accepted.

          - `const SequencePublishDraftResponseDefinitionStepObject6TypeWait SequencePublishDraftResponseDefinitionStepObject6Type = "WAIT"`

          - `const SequencePublishDraftResponseDefinitionStepObject6TypeWaitForConnection SequencePublishDraftResponseDefinitionStepObject6Type = "WAIT_FOR_CONNECTION"`

        - `Unit string`

          Unit of `duration`.

          - `const SequencePublishDraftResponseDefinitionStepObject6UnitDay SequencePublishDraftResponseDefinitionStepObject6Unit = "DAY"`

          - `const SequencePublishDraftResponseDefinitionStepObject6UnitMinute SequencePublishDraftResponseDefinitionStepObject6Unit = "MINUTE"`

  - `FirstActivatedAt string`

    When the sequence was first activated.

  - `LastActivatedAt string`

    When the sequence was most recently activated.

  - `Name string`

    Name of the sequence.

  - `ObjectType SequencePublishDraftResponseObjectType`

    Always `sequence`.

    - `const SequencePublishDraftResponseObjectTypeSequence SequencePublishDraftResponseObjectType = "sequence"`

  - `Reviewers []SequencePublishDraftResponseReviewer`

    Extra members who may approve this sequence’s `FOR_REVIEW` messages before they send. The sending member and the sequence’s creator always review, whether or not they are listed.

    - `ID string`

      ID of the member.

    - `ObjectType string`

      Always `member`.

      - `const SequencePublishDraftResponseReviewerObjectTypeMember SequencePublishDraftResponseReviewerObjectType = "member"`

  - `Senders []SequencePublishDraftResponseSender`

    The senders this sequence sends from; new contacts rotate across them. An archived sender stays listed but never sends; any change to the list drops it.

    - `ID string`

      ID of the sender.

    - `ObjectType string`

      Always `sender`.

      - `const SequencePublishDraftResponseSenderObjectTypeSender SequencePublishDraftResponseSenderObjectType = "sender"`

  - `Status SequencePublishDraftResponseStatus`

    `DRAFT` has not been published; `ACTIVE` is enabled for sending; `DEACTIVATED` is published but paused.

    - `const SequencePublishDraftResponseStatusDraft SequencePublishDraftResponseStatus = "DRAFT"`

    - `const SequencePublishDraftResponseStatusActive SequencePublishDraftResponseStatus = "ACTIVE"`

    - `const SequencePublishDraftResponseStatusDeactivated SequencePublishDraftResponseStatus = "DEACTIVATED"`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/Lightfld/lightfield-go"
  "github.com/Lightfld/lightfield-go/option"
)

func main() {
  client := githubcomlightfldlightfieldgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  sequencePublishDraftResponse, err := client.Sequence.PublishDraft(
    context.TODO(),
    "id",
    githubcomlightfldlightfieldgo.SequencePublishDraftParams{
      ExpectedVersion: "expectedVersion",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", sequencePublishDraftResponse.ID)
}
```

#### Response

```json
{
  "id": "id",
  "channels": [
    "EMAIL"
  ],
  "createdAt": "createdAt",
  "definition": {
    "description": "description",
    "messaging": {
      "callToAction": "callToAction",
      "persona": "persona",
      "trigger": "trigger",
      "valueProp": "valueProp"
    },
    "pacing": {
      "EMAIL": {
        "dailyLimit": -9007199254740991
      },
      "LINKEDIN_INVITE": {
        "dailyLimit": -9007199254740991
      },
      "LINKEDIN_MESSAGE": {
        "dailyLimit": -9007199254740991
      }
    },
    "priority": "HIGH",
    "sendWindow": {
      "daysOfWeek": [
        -9007199254740991
      ],
      "endHour": -9007199254740991,
      "startHour": -9007199254740991,
      "timezone": "timezone"
    },
    "steps": [
      {
        "id": "id",
        "deliveryMode": "AUTO",
        "mode": "AGENT",
        "name": "name",
        "prompt": "prompt",
        "type": "EMAIL"
      }
    ]
  },
  "firstActivatedAt": "firstActivatedAt",
  "lastActivatedAt": "lastActivatedAt",
  "name": "name",
  "objectType": "sequence",
  "reviewers": [
    {
      "id": "x",
      "objectType": "member"
    }
  ],
  "senders": [
    {
      "id": "x",
      "objectType": "sender"
    }
  ],
  "status": "DRAFT"
}
```
