# Profit Phones API

Base URL: https://profitphones.io/api/v1
Auth: send `Authorization: Bearer pfk_...` on every request. Make keys in the dashboard under API.
A key only ever sees the workspace it was made in, and only does what its scopes allow. A missing scope returns 403 with `missing_scope`.
The API is part of the Full plan. On other plans every request returns 402 until the workspace upgrades under Account.
JSON in, JSON out. Errors: `{ "error": "message" }` with a 4xx status. Limit: 300 requests per minute per key.
Phone ids look like `s1:R8YL617E3TL`. Times are ISO 8601 (UTC).

## Scopes

- `accounts:read`: See accounts, clients and which phone each one is on
- `accounts:write`: Add, change, move and remove accounts; check a phone for accounts
- `phones:read`: See phones, their status, screenshots, notes and proxies
- `phones:control`: Tap, swipe, type and open apps on phones; rename phones; manage notes and proxies
- `posts:read`: See posts and their results
- `posts:write`: Create, schedule, change and cancel posts
- `library:read`: See and download Library files
- `library:write`: Upload, move and delete Library files
- `analytics:read`: Read views, followers and best videos
- `automations:read`: See auto-posting and warm-up plans
- `automations:write`: Set up, pause, change and delete auto-posting and warm-up plans

## Workspace

Who the key belongs to and what it may do.

### GET /me
The workspace, plan and the scopes this key has.

### GET /scopes
Every scope and what it allows.

### GET /platforms
Platforms, the formats each takes, and whether Android phones and iPhones can post to it yet (android, iphone).

### GET /summary  (scope: accounts:read)
Counts at a glance: phones online, posts queued, posted today.

## Accounts

A social account (platform + handle) that lives on one phone.

### GET /accounts  (scope: accounts:read)
Every account with its phone, status, followers and queue.

### GET /accounts/detected  (scope: accounts:read)
Accounts the phones report as logged in.

### POST /accounts  (scope: accounts:write)
Add an account.

```json
{ "platform": "instagram_reels", "handle": "brandname", "device_id": "s1:R8YL…", "client_id": 3 }
```

### POST /accounts/locate  (scope: accounts:write)
Find which phone an account is logged in on (checks idle phones).

```json
{ "platform": "instagram_reels", "handle": "brandname" }
```

### PATCH /accounts/:id  (scope: accounts:write)
Move to another phone, pause, rename or set the client.

```json
{ "device_id": "s1:…", "paused": true, "display_name": "…", "client_id": 3 }
```

### DELETE /accounts/:id  (scope: accounts:write)
Remove an account. Its queued posts are removed too.

### POST /devices/:id/check  (scope: accounts:write)
Make a phone read which accounts are logged in (and their followers and views).

### GET /clients  (scope: accounts:read)
Clients (groups of accounts).

### POST /clients  (scope: accounts:write)
Add a client.

```json
{ "name": "Acme" }
```

### DELETE /clients/:id  (scope: accounts:write)
Remove a client.

## Phones

Phones plugged into your computers. Control actions are skipped while a phone is posting.

### GET /phones  (scope: phones:read)
Phones with online status and their accounts (simple list).

### GET /devices  (scope: phones:read)
Phones with full detail.

### GET /devices/:id/screen  (scope: phones:read)
A screenshot of the phone (image).

### GET /devices/:id/found  (scope: phones:read)
What the last account check found on this phone.

### GET /devices/:id/notes  (scope: phones:read)
Post-it notes on a phone.

### GET /watchdog  (scope: phones:read)
Every phone's health in plain words, with a fix for each problem.

### GET /apps  (scope: phones:read)
Apps you can open with /devices/:id/open.

### PATCH /devices/:id  (scope: phones:control)
Rename a phone or set its client.

```json
{ "label": "Rack 1 · 04", "client_id": 3 }
```

### POST /devices/:id/tap  (scope: phones:control)
Tap at a point, as fractions of the screen (0 to 1).

```json
{ "fx": 0.5, "fy": 0.82 }
```

### POST /devices/:id/swipe  (scope: phones:control)
Swipe between two points (fractions of the screen).

```json
{ "fx1": 0.5, "fy1": 0.8, "fx2": 0.5, "fy2": 0.3, "ms": 300 }
```

### POST /devices/:id/text  (scope: phones:control)
Type into the selected field.

```json
{ "text": "hello" }
```

### POST /devices/:id/key  (scope: phones:control)
Press back, home, recents or wake.

```json
{ "key": "home" }
```

### POST /devices/:id/press  (scope: phones:control)
Press a hardware key (volume, power and others).

```json
{ "key": "volup" }
```

### POST /devices/:id/open  (scope: phones:control)
Open an app.

```json
{ "app": "instagram" }
```

### POST /devices-bulk  (scope: phones:control)
Open an app or press a key on many phones at once.

```json
{ "ids": ["s1:…"], "app": "instagram" }
```

### POST /devices/:id/notes  (scope: phones:control)
Add a note to a phone.

```json
{ "text": "Needs a new SIM" }
```

### DELETE /notes/:id  (scope: phones:control)
Remove a note.

### DELETE /devices/:id  (scope: phones:control)
Forget an unplugged phone.

### GET /proxies  (scope: phones:read)
Proxies and which account uses each.

### POST /proxies  (scope: phones:control)
Add proxies, one per line.

```json
{ "lines": "host:port:user:pass" }
```

### PATCH /proxies/:id  (scope: phones:control)
Note which account a proxy belongs to. The phones do not switch to it on their own yet; set the proxy on the phone itself.

```json
{ "account_id": 12 }
```

### POST /proxies/check  (scope: phones:control)
Test that the proxies answer.

### DELETE /proxies/:id  (scope: phones:control)
Remove a proxy.

## Posts

One video going to one account. Status: importing, queued, running, then posted, or failed / needs_review. format says what it posts as: "reel" (an Instagram Reel, a TikTok video or a YouTube Short) or "story" (Instagram only). A Story can carry a link, shown as a link sticker. A post waiting on something it can't fix itself (for example a phone type that can't post that platform yet) stays queued with the reason in error.

### GET /posts  (scope: posts:read)
Posts, newest first. Filters: status, account_id, external_id, updated_since, limit (max 500).

### GET /posts/:id  (scope: posts:read)
One post.

### POST /posts  (scope: posts:write)
Schedule a video. Send a file as multipart "video", or JSON with video_url (direct https file) or source_url (Instagram/TikTok/YouTube link). Pick the account by account_id or platform + handle. external_id makes retries safe (same id returns the existing post). format: reel (default), story or both (Instagram only; both makes a reel and a story from the same video, the story is returned under "also"). link: optional https link for the story sticker.

```json
{ "account_id": 12, "video_url": "https://…/clip.mp4", "caption": "…", "scheduled_at": "2026-11-10T15:00:00Z", "mode": "publish", "format": "reel|story|both", "link": "https://yoursite.com", "external_id": "my-123" }
```

### PATCH /posts/:id  (scope: posts:write)
Change caption, time, format (reel or story) or story link, retry, or mark as posted.

```json
{ "caption": "…", "scheduled_at": "…", "format": "story", "link": "https://…", "action": "retry" }
```

### DELETE /posts/:id  (scope: posts:write)
Cancel a post that hasn't gone out.

### POST /import  (scope: posts:write)
Queue many social links at once, spaced out.

```json
{ "account_id": 12, "urls": "https://… https://…", "spacing_minutes": 60, "use_original_caption": true, "format": "reel|story|both", "link": "https://…" }
```

### GET /inbox  (scope: posts:read)
Links shared to the dashboard from the phones.

### POST /inbox/clear  (scope: posts:write)
Clear shared links.

```json
{ "ids": [1, 2] }
```

## Library

Your stored videos and images, filed per account or Shared.

### GET /library  (scope: library:read)
Files and the folder tree. Query: folder=all|shared|favorites|<account id>, kind=video|image, q.

### GET /library/file/:id  (scope: library:read)
Download a file.

### GET /library/thumb/:id  (scope: library:read)
A file's thumbnail.

### POST /library  (scope: library:write)
Upload files as multipart "files" (up to 200). Add account_id to file them under that account, or leave it out for Shared.

### PATCH /library  (scope: library:write)
Move files to an account (or Shared with null), or favorite them.

```json
{ "ids": [5, 6], "account_id": 12, "favorite": true }
```

### DELETE /library  (scope: library:write)
Delete files.

```json
{ "ids": [5, 6] }
```

### POST /library/post  (scope: posts:write)
Turn Library videos into scheduled posts.

```json
{ "ids": [5, 6], "account_id": 12, "start_at": "…", "spacing_minutes": 60, "caption": "…", "format": "reel|story|both", "link": "https://…" }
```

## Analytics

Read from the phones every hour.

### GET /analytics  (scope: analytics:read)
Total views, followers, growth, daily series, per account numbers and best videos. Query: days=7|30|90.

## Automations

Things that run by themselves. "live" on each one is the real state right now (for example phone_off when the phone is disconnected).

### GET /autopost  (scope: automations:read)
Auto-posting rules with live status. Query: device_id to limit to one phone.

### GET /autopost/:id  (scope: automations:read)
One rule with its recent posts.

### POST /autopost  (scope: automations:write)
Start auto-posting the videos in each account's Library folder. One rule per account. format: reel (default), story or both (Instagram only; both posts every video as a reel and as a story). link: optional story link sticker.

```json
{ "account_ids": [12], "per_day": 3, "hour_from": 9, "hour_to": 21, "timezone": "America/New_York", "caption_mode": "same|filename|none", "caption": "…", "use_shared": false, "mode": "publish", "format": "reel|story|both", "link": "https://yoursite.com" }
```

### PUT /autopost/:id  (scope: automations:write)
Pause, resume or change a rule (any field from POST, plus status).

```json
{ "status": "paused", "per_day": 2, "format": "both" }
```

### DELETE /autopost/:id  (scope: automations:write)
Stop auto-posting. Videos stay in the Library.

### GET /warmup  (scope: automations:read)
Warm-up plans with live status. Plans are saved and can be switched on, but the phones do not run warm-up sessions yet. They start once warm-up goes live.

### POST /warmup  (scope: automations:write)
Create a warm-up plan.

```json
{ "name": "…", "status": "active", "settings": { … }, "account_ids": [12] }
```

### PUT /warmup/:id  (scope: automations:write)
Change, pause or switch on a plan.

### DELETE /warmup/:id  (scope: automations:write)
Delete a plan.

## Typical agent flow

1. `GET /me` to see the scopes. 2. `GET /accounts` to pick accounts that have `can_post: true` (`phone_support` says why a phone can't post that platform yet).
3. Upload a batch with `POST /library` (account_id), then `POST /autopost` to post it a few a day, or `POST /posts` for exact times.
4. Watch `GET /posts?updated_since=…` and `GET /autopost` (live status), and read results from `GET /analytics`.
