[MCPサーバー](https://to.co/ja-jp/docs/mcp?format=md) · **API**

# to.co API

Webサイト、POSシステム、スクリプトなど、自社のソフトウェアからto.co上の会社の情報を読み取り、最新の状態に保てます。APIキーはProプランとGrowプランで使えます。

- ベースURL: `https://api.to.co/v1/orgs/{host}`
- 認証: `Authorization: Bearer toco_ak_…`

## APIキーを取得する

my.to.coで会社を開き、「APIキー」から「キーを作成」を選びます。名前、スコープ、有効期限（最長1年）を設定し、キーをコピーしてください。キーは一度しか表示されず、保存されるのはハッシュのみです。

すべてのリクエストで、キーをAuthorizationヘッダーで送信してください。キーは自分の会社でのみ使え、他のアドレスでは「見つかりません」が返されます。APIはキーのみを受け付け、ブラウザのセッションは受け付けません。

呼び出し例:

```shell
curl https://api.to.co/v1/orgs/mybusiness.uk.to.co \
  -H "Authorization: Bearer toco_ak_…"
```

## スコープとプラン

キーができるのは、スコープで許可された操作のうち、各リクエストの時点で会社のプランに含まれるものだけです。読み取りはProプランとGrowプランで、変更はGrowプランで使えます。

| スコープ | できること | 対象プラン |
|---|---|---|
| `company:read` | Your company details, services and locations. | Pro |
| `messages:read` | Messages from your contact form (not those held as spam). | Pro |
| `company:write` | Replace your services, and change phone numbers and opening hours. | Grow |
| `posts:read` | The posts you write on to.co, drafts included. | Pro |
| `posts:write` | Write, save, publish, unpublish and delete posts. | Grow |

## ルート

すべてのルートはベースURLの下にあり、`{host}`の部分を会社のto.coアドレス（例：mybusiness.uk.to.co）に置き換えて使います。リクエストと応答はJSONです。変更は、my.to.coでの変更と同じチェック、履歴、再公開の処理を経て、キーによる変更として記録されます。

| ルート | できること | スコープ |
|---|---|---|
| `GET /v1/orgs/{host}` | The company record, with its services and locations. | `company:read` |
| `GET /v1/orgs/{host}/services` | The services, in order. | `company:read` |
| `GET /v1/orgs/{host}/locations` | The locations, with phones and opening hours. | `company:read` |
| `GET /v1/orgs/{host}/messages` | Contact form messages. Filter with ?status=new\|read\|replied\|archived. | `messages:read` |
| `GET /v1/orgs/{host}/messages/{id}` | One message. | `messages:read` |
| `PATCH /v1/orgs/{host}` | Change the company phone numbers: JSON { "phones": … }. | `company:write` |
| `PUT /v1/orgs/{host}/services` | Replace the whole list of services, in order: JSON { "services": [ … ] }. | `company:write` |
| `PATCH /v1/orgs/{host}/locations/{location}` | Change a location: JSON with any of phones, normal_hours and special_hours. Every value is checked, and the answer carries the checks. The registered office comes from the register and cannot be changed. | `company:write` |
| `GET /v1/orgs/{host}/posts` | Posts written on to.co, newest change first, a page at a time: ?limit, ?state and ?cursor (next_cursor from the page before). | `posts:read` |
| `GET /v1/orgs/{host}/posts/{id}` | One post, its body as blocks, with its version as the ETag. | `posts:read` |
| `POST /v1/orgs/{host}/posts` | A new draft: JSON { "title", "standfirst", "body" }, or the body as text/markdown. | `posts:write` |
| `PATCH /v1/orgs/{host}/posts/{id}` | Save a post. Send the version you are changing as If-Match; JSON, or the body as text/markdown. | `posts:write` |
| `DELETE /v1/orgs/{host}/posts/{id}` | Move a post to the bin. The owner can restore it in my.to.co for 30 days. | `posts:write` |
| `POST /v1/orgs/{host}/posts/{id}/publish` | Publish the If-Match version. It is checked first, as when the owner publishes. | `posts:write` |
| `POST /v1/orgs/{host}/posts/{id}/unpublish` | Take a post off the page and back to a draft. | `posts:write` |

## クレジットと制限

- 各リクエストは、事業のMCPサーバーへの自分のAIアシスタントからの呼び出しと同じ月間枠から、APIクレジットを1つ使います。会社ごとに、Proプランでは月5,000、Growプランでは月50,000です。失敗したリクエストのクレジットは戻ります。クレジットは毎月1日（UTC）にリセットされ、超過料金はかかりません。応答にはX-Credits-Limit、X-Credits-Remaining、X-Credits-Resetが含まれます。
- キーごとに1分あたり最大120リクエストです。
- 会社ごとに1分あたり最大60件の変更で、my.to.coとMCPでの変更も合わせて数えます。

## エラー

エラーは、HTTPステータスと、error（メッセージ）、code（以下のいずれか）、request_idを含むJSONで返されます。429にはRetry-Afterが含まれます。

- `invalid_request` (400): The body or a query value is not valid; the message says which field.
- `cookie_not_accepted` (400): The request carried a browser session. This API takes an API key only.
- `if_match_required` (400): A post change without If-Match.
- `not_ready` (400): The post cannot be published yet; problems lists why.
- `image_unknown` (400): A post body shows an image the post does not have. A key cannot upload images.
- `invalid_key` (401): No key, or one that is unknown, revoked or expired.
- `insufficient_scope` (403): The key does not have the scope this route needs.
- `plan_required` (403): The company plan does not include this scope now; plan_needed names the plan that does.
- `insufficient_role` (403): The person who made the key no longer has the role for this; an owner makes a new key.
- `not_found` (404): Not found. A host other than the key's own company is always not found.
- `registered_office` (409): The registered office comes from the company register and cannot be changed with a key.
- `post_changed` (409): The post changed since the If-Match version. Read it again.
- `post_deleted` (409): The post is in the bin.
- `not_draft` (409): Only a draft can be scheduled.
- `slug_taken` (409): Another post already uses that address.
- `rate_limited` (429): Too many requests. Wait for Retry-After.
- `credits_exhausted` (429): This month's API credits are used. They start again on the first of next month; there are no overage charges.
- `credits_unavailable` (503): The API cannot count credits right now. Try again later.

## Webhook

Growプランでは、新しいメッセージや会社情報の変更など何かが変わったときに、to.coから自社のサーバーに署名付きのイベントを送ることもできます。my.to.coの「Webhook」で設定してください。

## 次のステップ

- [AIアシスタント向けのto.co MCPサーバー](https://to.co/ja-jp/docs/mcp?format=md)
- [my.to.coを開く](https://my.to.co)
