---
title: "Creates an automation; an unlock needs customer:write too, a price adjustment discount:write, and each needs the read scope of what it names."
---

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

Path: Sherpo merchant API › automation

`POST /v1/stores/{store}/automations`

## Authentication

- `bearer`, http, header `Authorization`, scopes: `automation:write`

## Path parameters

- `store` (`createAutomation.path.store`; string, required) — The store's id.

## Header parameters

- `Idempotency-Key` (`createAutomation.header.Idempotency-Key`; string, optional) — Repeats within 24 hours answer the first result; the same key with other arguments is a conflict.
  - minLength 1; maxLength 255; pattern `^[\x21-\x7E]+$`

## Request body

_Required._

- `trigger` (`createAutomation.trigger`; any of, required)
  - any of: `object`, `object`, `object`
- `action` (`createAutomation.action`; any of, required)
  - any of: `object`, `object`
- `name` (`createAutomation.name`; any of, optional)
  - any of: `string`, `null`

## Example request

```json
{
  "name": "string",
  "trigger": {
    "kind": "product.purchased",
    "product": {
      "id": "string"
    },
    "price": {
      "id": "string"
    },
    "discount": {
      "id": "string"
    }
  },
  "action": {
    "kind": "product.unlock",
    "product": {
      "id": "string"
    }
  }
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.sherpo.io/merchant/v1/stores/<store>/automations' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "string",
  "trigger": {
    "kind": "product.purchased",
    "product": {
      "id": "string"
    },
    "price": {
      "id": "string"
    },
    "discount": {
      "id": "string"
    }
  },
  "action": {
    "kind": "product.unlock",
    "product": {
      "id": "string"
    }
  }
}
'
```

### TypeScript

```typescript
const url = 'https://api.sherpo.io/merchant/v1/stores/<store>/automations';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    name: 'string',
    trigger: {
      kind: 'product.purchased',
      product: {id: 'string'},
      price: {id: 'string'},
      discount: {id: 'string'}
    },
    action: {kind: 'product.unlock', product: {id: 'string'}}
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.sherpo.io/merchant/v1/stores/<store>/automations"

payload = {
    "name": "string",
    "trigger": {
        "kind": "product.purchased",
        "product": { "id": "string" },
        "price": { "id": "string" },
        "discount": { "id": "string" }
    },
    "action": {
        "kind": "product.unlock",
        "product": { "id": "string" }
    }
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 201

Creates an automation; an unlock needs customer:write too, a price adjustment discount:write, and each needs the read scope of what it names.

#### Example

```json
{
  "trigger": {
    "product": {
      "id": "string",
      "slug": "string",
      "path": "string",
      "url": "string",
      "title": "string",
      "category": "string",
      "deleted": true
    },
    "kind": "product.reviewed",
    "product_id": "string",
    "min_rating": 0
  },
  "action": {
    "product": {
      "id": "string",
      "slug": "string",
      "path": "string",
      "url": "string",
      "title": "string",
      "category": "string",
      "deleted": true
    },
    "kind": "product.unlock",
    "product_id": "string"
  },
  "ended": true,
  "id": "string",
  "name": "string",
  "paused_at": "string",
  "token_id": "string",
  "created_at": "string"
}
```

- `trigger` (`createAutomation.response.201.trigger`; any of, required)
  - any of: `object`, `object`, `object`
- `action` (`createAutomation.response.201.action`; any of, required)
  - any of: `object`, `object`
- `ended` (`createAutomation.response.201.ended`; boolean, required)
- `id` (`createAutomation.response.201.id`; string, required)
- `name` (`createAutomation.response.201.name`; any of, required)
  - any of: `string`, `null`
- `paused_at` (`createAutomation.response.201.paused_at`; any of, required)
  - any of: `string`, `null`
- `token_id` (`createAutomation.response.201.token_id`; any of, required)
  - any of: `string`, `null`
- `created_at` (`createAutomation.response.201.created_at`; any of, required)
  - any of: `string`, `null`

### default

A problem; see https://api.sherpo.io/merchant/docs/errors.

#### Example

```json
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "string",
  "context": {},
  "reached_core": true,
  "core_answer": "string"
}
```

- `type` (`createAutomation.response.default.type`; string, required)
  - format `uri`
- `title` (`createAutomation.response.default.title`; string, required)
- `status` (`createAutomation.response.default.status`; integer, required)
- `detail` (`createAutomation.response.default.detail`; string, required)
- `code` (`createAutomation.response.default.code`; string, optional)
- `context` (`createAutomation.response.default.context`; object, optional)
- `reached_core` (`createAutomation.response.default.reached_core`; boolean, optional)
- `core_answer` (`createAutomation.response.default.core_answer`; string, optional)


Source: https://docs.sherpo.io/merchant-api/reference/create-automation/index.md
