# Replace LinkedIn campaign steps

Source: https://docs.emelia.io/docs/campaigns/legacy/linkedin/replace-steps

Guide: [LinkedIn campaigns](https://docs.emelia.io/docs/campaigns/legacy/linkedin.md)

`PATCH https://api.emelia.io/linkedin/campaigns/{campaignId}/steps`

Replaces the full ordered list of LinkedIn steps. The campaign must not be RUNNING or ARCHIVED. Steps after the first need delay.amount > 0; at most one disabled version per step. New integrations should use the multichannel /advanced campaign endpoints instead.

> **Deprecated.**

## Authentication

Send your API key in the `Authorization` header: `Authorization: <your API key>`.

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `campaignId` | string | yes | Mongo ObjectId of the campaign. |

## Request body

Content type: `application/json`, required.

| Field | Type | Required | Description |
|---|---|---|---|
| `steps` | array of object | yes |  |
| `steps[].stepType` | enum: `VISIT`, `CONNECTION`, `MESSAGE`, `LIKE`, `FOLLOW`, `INMAIL` | yes | `FOLLOW` is accepted when saved, but nothing runs it: do not use it. |
| `steps[].delay` | object | yes |  |
| `steps[].delay.amount` | integer | no | Must be > 0 for steps after the first. Range: 0 to 10000. |
| `steps[].delay.unit` | enum: `MINUTES`, `HOURS`, `DAYS` | yes |  |
| `steps[].versions` | array of object | yes | At most one disabled version per step. VISIT/LIKE/FOLLOW steps can carry an empty versions array. |
| `steps[].versions[].disabled` | boolean | no |  |
| `steps[].versions[].message` | string | no |  |
| `steps[].versions[].attachments` | array of object | no |  |

```json
{
  "steps": [
    {
      "stepType": "VISIT",
      "delay": {
        "amount": 0,
        "unit": "DAYS"
      },
      "versions": []
    },
    {
      "stepType": "CONNECTION",
      "delay": {
        "amount": 1,
        "unit": "DAYS"
      },
      "versions": [
        {
          "message": "Hi {{firstName}}, happy to connect."
        }
      ]
    }
  ]
}
```

## Example request

**cURL**

```bash
curl -X PATCH "https://api.emelia.io/linkedin/campaigns/65f1a2b3c4d5e6f73478765e/steps" \
  -H "Authorization: $EMELIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "steps": [
    {
      "stepType": "VISIT",
      "delay": {
        "amount": 0,
        "unit": "DAYS"
      },
      "versions": []
    },
    {
      "stepType": "CONNECTION",
      "delay": {
        "amount": 1,
        "unit": "DAYS"
      },
      "versions": [
        {
          "message": "Hi {{firstName}}, happy to connect."
        }
      ]
    }
  ]
}'
```

**JavaScript**

```js
const response = await fetch('https://api.emelia.io/linkedin/campaigns/65f1a2b3c4d5e6f73478765e/steps', {
  method: 'PATCH',
  headers: { Authorization: process.env.EMELIA_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "steps": [
      {
        "stepType": "VISIT",
        "delay": {
          "amount": 0,
          "unit": "DAYS"
        },
        "versions": []
      },
      {
        "stepType": "CONNECTION",
        "delay": {
          "amount": 1,
          "unit": "DAYS"
        },
        "versions": [
          {
            "message": "Hi {{firstName}}, happy to connect."
          }
        ]
      }
    ]
  }),
});
console.log(await response.json());
```

**Python**

```python
import os
import requests

response = requests.patch(
    "https://api.emelia.io/linkedin/campaigns/65f1a2b3c4d5e6f73478765e/steps",
    headers={"Authorization": os.environ["EMELIA_API_KEY"]},
    json={
        "steps": [
            {
                "stepType": "VISIT",
                "delay": {
                    "amount": 0,
                    "unit": "DAYS"
                },
                "versions": []
            },
            {
                "stepType": "CONNECTION",
                "delay": {
                    "amount": 1,
                    "unit": "DAYS"
                },
                "versions": [
                    {
                        "message": "Hi {{firstName}}, happy to connect."
                    }
                ]
            }
        ]
    },
)
print(response.json())
```

## Responses

### 200: Updated campaign.

| Field | Type | Required | Description |
|---|---|---|---|
| `success` | enum: `true` | yes |  |
| `campaign` | object | yes | A full LinkedIn campaign document. |
| `campaign._id` | string | no |  |
| `campaign.userId` | string | no |  |
| `campaign.name` | string | no |  |
| `campaign.status` | enum: `DRAFT`, `RUNNING`, `PAUSED`, `FINISHED`, `ARCHIVED` | no |  |
| `campaign.account` | string or null | no | LinkedIn account (authe) id. |
| `campaign.schedule` | object | no |  |
| `campaign.steps` | array of object | no |  |
| `campaign.recipients` | object | no |  |
| `campaign.createdAt` | string (date-time) | no |  |
| `campaign.startAt` | string (date-time) | no |  |
| `campaign.estimatedEnd` | string (date-time) | no |  |
| `campaign.plannedStart` | string (date-time) | no |  |

```json
{
  "success": true,
  "campaign": {
    "_id": "6650f1a2b839d800941eec2c",
    "userId": "6650f1a2b839d800d0a32198",
    "name": "Q4 outreach: SaaS founders",
    "status": "DRAFT",
    "account": "6650f1a2b839d800463fada8",
    "schedule": {
      "dailyContact": 35,
      "timeZone": "Europe/Paris",
      "days": [
        1
      ],
      "start": "08:00",
      "end": "17:00",
      "excludeAlreadyMessaged": true,
      "exclude1stConn": true,
      "excludeNoPictures": true
    },
    "steps": [
      {
        "_id": "6650f1a2b839d80036a70635",
        "stepType": "VISIT",
        "delay": {
          "amount": 1,
          "unit": "DAYS"
        },
        "versions": [
          {
            "_id": "6650f1a2b839d800f3a30d30",
            "message": "Hi Claire, thanks for your reply. Are you free for a call on Thursday?",
            "disabled": false,
            "attachments": []
          }
        ]
      }
    ],
    "recipients": {
      "lists": [
        {}
      ],
      "contacts": [
        "6650f1a2b839d800fd48d7a4"
      ],
      "processing": true
    },
    "createdAt": "2026-10-06T09:30:00.000Z",
    "startAt": "2026-10-06T09:30:00.000Z",
    "estimatedEnd": "2026-10-06T09:30:00.000Z",
    "plannedStart": "2026-10-06T09:30:00.000Z"
  }
}
```

### 400: Business or validation error. 400 by default; Joi validation errors carry code INVALID_REQUEST.

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | string or object | yes | Human readable message. A few legacy routes return an empty object `{}` here instead of a string. |
| `code` | enum: `INVALID_REQUEST`, `INVALID_PARAMETERS`, `SUBSCRIPTION_REQUIRED`, `CAMPAIGN_NOT_FOUND`, `CAMPAIGN_ALREADY_RUNNING`, `SCHEDULE_MISSING`, `STEPS_MISSING`, `NO_RECIPIENTS`, `TOO_MANY_RECIPIENTS`, `PLANNED_START_INVALID`, `PLANNED_START_IN_PAST`, `EMAIL_PROVIDER_MISSING`, `EMAIL_PROVIDER_DISCONNECTED`, `EMAIL_PROVIDER_EXPIRED`, `ONE_EMAIL_PROVIDER_EXPIRED`, `EMAIL_ADDRESS_DISCONNECTED`, `TRACKING_DOMAINS_REQUIRED`, `LINKEDIN_ACCOUNT_MISSING`, `LINKEDIN_COOKIE_EXPIRED`, `LINKEDIN_SLOT_EXPIRED`, `WHATSAPP_ACCOUNT_EXPIRED`, `WHATSAPP_SLOT_EXPIRED`, `NO_IDENTITY_SET`, `IDENTITY_FOREIGN_ACCOUNT`, `IDENTITY_EMAIL_PROVIDER_MISSING`, `LINKEDIN_ACCOUNT_AMBIGUOUS`, `WHATSAPP_ACCOUNT_AMBIGUOUS`, `LINKEDIN_AUDIO_MISSING`, `EMAIL_STEP_NO_ACTIVE_VERSION`, `EMAIL_VERSION_NO_CONTENT`, `EMAIL_VERSION_NO_SUBJECT`, `RECIPIENTS_NO_EMAIL`, `RECIPIENTS_NO_LINKEDIN`, `MC_LINKEDIN_DAILY_LIMIT_CONNECTION`, `MC_LINKEDIN_DAILY_LIMIT`, `DAILY_CONTACT_TOO_LOW`, `LINKEDIN_DAILY_CONTACT_LIMIT`, `VERIFY_EMAIL_TOKEN_INVALID`, `VERIFY_EMAIL_TOKEN_EXPIRED`, `FREE_CREDITS_DOMAIN_ALREADY_CLAIMED`, `FREE_CREDITS_ALREADY_GRANTED`, `FREE_CREDITS_NOT_ELIGIBLE`, `RATE_LIMITED`, `STATS_COMPUTING`, `WARMUP_PROVIDER_UNSUPPORTED`, `ACCOUNT_DISCONNECTED` | no | Stable machine readable error code. Present only on catalogued errors (mainly the campaign start checks), on validation errors (`INVALID_REQUEST`) and on some LinkedIn provider errors (`ACCOUNT_DISCONNECTED`, `RATE_LIMITED`). Most other errors have no code: rely on the HTTP status and on `error`. Codes are never renamed once deployed. |
| `params` | object | no | Values interpolated in the message, for example `{"max": 30000}`. |

```json
{
  "error": "string",
  "code": "INVALID_REQUEST",
  "params": {}
}
```
