---
title: "Arm a plug on a post"
method: POST
path: "/posts/{id}/plugs"
tags: ["Posts"]
---

# Arm a plug on a post

`POST /posts/{id}/plugs`

## Request

- Base URL: `https://www.sociahive.com/api/v1`
- URL: `https://www.sociahive.com/api/v1/posts/{id}/plugs`
- Auth: one of:
  - API key in header `X-API-Key`
  - OAuth 2 (authorization code, authorization URL `/api/oauth/authorize`, token URL `/api/oauth/token`, scopes: `posts:write`)

Watches the target and fires once when the metric reaches the threshold: repost (X) or add a comment (X, Instagram, Facebook, LinkedIn company pages). The post must be scheduled or live. At most 3 plugs per target and 10 armed per user. X is checked every 30 minutes for 24 hours; Instagram, Facebook and LinkedIn pages every 5 minutes for the first hour, then every 30, for 48 hours. A personal LinkedIn account cannot carry a plug.

## Path parameters

- `id` string, required: MongoDB ObjectId (24-character hex string)

## Request body

- ArmPlugRequest
  - `account_id` string, required: MongoDB ObjectId (24-character hex string)
  - `trigger` object, required
    - `metric` 'likes' | 'comments' | 'reposts' | 'views', required
    - `threshold` integer, required
  - `action` object, required
    - `kind` 'repost' | 'comment', required
    - `text` string: Required for `comment`. On X a comment is a reply under the post.

## Response `201`

Plug armed

- object
  - `success` true, required
  - `data` Plug, required
    - `id` string, required: MongoDB ObjectId (24-character hex string)
    - `post_id` string, required: MongoDB ObjectId (24-character hex string)
    - `account_id` string, required: The connected account (post target) the plug watches.
    - `trigger` object, required
      - `metric` 'likes' | 'comments' | 'reposts' | 'views', required
      - `threshold` integer, required
    - `action` object, required
      - `kind` 'repost' | 'comment', required
      - `text` string
    - `state` 'armed' | 'fired' | 'expired' | 'failed', required: armed: watching (or firing). fired: the action ran once. expired: the window ended, or the post was deleted. failed: see error.
    - `last_value` integer: Last value read from the platform.
    - `last_checked_at` string, date-time
    - `fired_at` string, date-time
    - `expires_at` string, date-time, required
    - `error` object: Why the plug failed or ended, or a read problem while it keeps watching. AMBIGUOUS_MAY_HAVE_POSTED: check the platform before arming again.
      - `code` string, required
      - `message` string, required
    - `created_at` string, date-time, required

## Other responses

- `400`: Bad request — invalid parameters
- `401`: Authentication required — provide X-API-Key or Bearer token
- `403`: Insufficient scope for this operation
- `404`: Post or target not found
- `409`: Post not scheduled, target failed, post too old, or a plug limit reached (see `code`)
- `429`: Rate limit exceeded
- `500`: Internal server error

---

[API](https://skmtc.dev/sociahive/apis/sociahive-api.md) · [All operations](https://skmtc.dev/sociahive/apis/sociahive-api/llms.txt) · [OpenAPI document](https://skmtc.dev/sociahive/apis/sociahive-api/revisions/791b8548d288?raw)
