# Test helpers

> 3 endpoints: add a test account, change a test account's behaviour, advance a post.

- [Add a test account](#add-a-test-account): `POST /v1/test_helpers/accounts`
- [Change a test account's behaviour](#change-a-test-account-s-behaviour): `POST /v1/test_helpers/accounts/{account_id}`
- [Advance a post](#advance-a-post): `POST /v1/test_helpers/posts/{post_id}/advance`

### Add a test account

`POST /v1/test_helpers/accounts`

Adds a simulated account of a network to a Project in this sandbox, at once. It never reaches the network: posts to it publish through the simulator, following its preset and your caption's magic values. Plan limits per network apply as for real accounts. Test keys only.

Permission: `accounts:write` · Accepts `Idempotency-Key` · Answers `201`

#### Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `project_id` | string | Yes |  (up to 128 characters) |
| `network` | `youtube`, `tiktok`, `instagram`, `facebook`, `threads`, `bluesky`, `mastodon`, `pinterest`, `telegram`, `twitch`, `x`, `discord` | Yes |  |
| `preset` | `healthy`, `reauth_required`, `expiring`, `slow`, `flaky` | No | How the simulated network behaves: healthy, reauth_required, expiring, slow (publishes 90 seconds late) or flaky (about 3 in 10 targets fail). (default "healthy") |
| `name` | string | No |  (up to 120 characters) |

#### Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | `"account"` | Yes |  |
| `id` | string | Yes |  (up to 128 characters) |
| `project_id` | string or null | Yes |  |
| `network` | `youtube`, `tiktok`, `instagram`, `facebook`, `threads`, `bluesky`, `mastodon`, `pinterest`, `telegram`, `twitch`, `x`, `discord` | Yes |  |
| `name` | string | Yes |  |
| `handle` | string or null | Yes |  |
| `avatar_url` | string or null | Yes |  |
| `followers` | integer or null | Yes |  |
| `status` | `active`, `reconnect_required`, `error` | Yes |  |
| `connected_at` | string | Yes | ISO 8601 date and time, UTC. |

```bash
curl -X POST https://api.nowscale.com/v1/test_helpers/accounts \
  -H "Authorization: Bearer $NOWSCALE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{ ... }'
```

### Change a test account's behaviour

`POST /v1/test_helpers/accounts/{account_id}`

Switches a test account's preset, for example to reauth_required to see how your integration handles an account that must reconnect, then back to healthy. Test keys only.

Permission: `accounts:write`

#### Path parameters

| Name | Description |
| --- | --- |
| `account_id` | The account's id. |

#### Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `preset` | `healthy`, `reauth_required`, `expiring`, `slow`, `flaky` | Yes |  |

#### Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | `"account"` | Yes |  |
| `id` | string | Yes |  (up to 128 characters) |
| `project_id` | string or null | Yes |  |
| `network` | `youtube`, `tiktok`, `instagram`, `facebook`, `threads`, `bluesky`, `mastodon`, `pinterest`, `telegram`, `twitch`, `x`, `discord` | Yes |  |
| `name` | string | Yes |  |
| `handle` | string or null | Yes |  |
| `avatar_url` | string or null | Yes |  |
| `followers` | integer or null | Yes |  |
| `status` | `active`, `reconnect_required`, `error` | Yes |  |
| `connected_at` | string | Yes | ISO 8601 date and time, UTC. |

```bash
curl -X POST https://api.nowscale.com/v1/test_helpers/accounts/ACCOUNT_ID \
  -H "Authorization: Bearer $NOWSCALE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ ... }'
```

### Advance a post

`POST /v1/test_helpers/posts/{post_id}/advance`

Runs the simulator for this post now: every target whose time has come, including ones held by a delay, publishes or fails right away instead of on the next worker run. A target scheduled in the future stays scheduled; publish the post to send it now. Answers with the post after the simulator ran. Test keys only.

Permission: `posts:publish` · Accepts `Idempotency-Key`

#### Path parameters

| Name | Description |
| --- | --- |
| `post_id` | The post's id. |

#### Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | `"post"` | Yes |  |
| `id` | string | Yes |  (up to 128 characters) |
| `project_id` | string or null | Yes |  |
| `status` | `draft`, `scheduled`, `publishing`, `published`, `partial`, `failed`, `deleting` | Yes |  |
| `review_status` | `not_required`, `draft`, `in_review`, `approved`, `rejected` | Yes |  |
| `title` | string or null | Yes |  |
| `caption` | string or null | Yes |  |
| `visibility` | string | Yes |  |
| `scheduled_at` | string or null | Yes |  |
| `published_at` | string or null | Yes |  |
| `created_at` | string | Yes | ISO 8601 date and time, UTC. |
| `updated_at` | string | Yes | ISO 8601 date and time, UTC. |
| `targets` | array of object | Yes |  |
| `targets[].object` | `"post_target"` | Yes |  |
| `targets[].id` | string | Yes |  (up to 128 characters) |
| `targets[].account_id` | string | Yes |  (up to 128 characters) |
| `targets[].network` | `youtube`, `tiktok`, `instagram`, `facebook`, `threads`, `bluesky`, `mastodon`, `pinterest`, `telegram`, `twitch`, `x`, `discord` | Yes |  |
| `targets[].status` | `pending`, `uploading`, `uploaded`, `published`, `failed` | Yes |  |
| `targets[].stage` | string | Yes |  |
| `targets[].external_id` | string or null | Yes |  |
| `targets[].error_code` | string or null | Yes |  |
| `targets[].scheduled_at` | string or null | Yes |  |

```bash
curl -X POST https://api.nowscale.com/v1/test_helpers/posts/POST_ID/advance \
  -H "Authorization: Bearer $NOWSCALE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{ ... }'
```
