דף הבית של to.co

ה-API של to.co

אפשר לתת לתוכנה שלכם, כמו אתר, מערכת קופה או סקריפט, לקרוא את החברה שלכם ב-to.co ולשמור אותה מעודכנת. מפתחות זמינים ב-Pro וב-Grow.

קבלת מפתח API נתיבים

כתובת בסיס
https://api.to.co/v1/orgs/{host}
אימות גישה
Authorization: Bearer toco_ak_…

קבלת מפתח API

יש לפתוח את החברה שלכם ב-my.to.co ולבחור "מפתחות API", ואז "יצירת מפתח". נותנים לו שם, בוחרים את ההרשאות שלו ומתי התוקף שלו פג (שנה לכל היותר), ומעתיקים אותו: הוא מוצג פעם אחת ונשמר רק hash שלו.

יש לשלוח את המפתח בכותרת Authorization בכל בקשה. מפתח עובד רק לחברה שלו: כל כתובת אחרת עונה "לא נמצא". ה-API מקבל רק מפתחות, אף פעם לא סשן של דפדפן.

קריאה לדוגמה

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

הרשאות ותוכניות

מפתח יכול לעשות רק מה שההרשאות שלו מאפשרות, ורק מה שהתוכנית של החברה כוללת ברגע כל בקשה. קריאה זמינה ב-Pro וב-Grow; שינויים ב-Grow.

הרשאהמה היא עושהמתוכנית
company:readYour company details, services and locations.Pro
messages:readMessages from your contact form (not those held as spam).Pro
company:writeReplace your services, and change phone numbers and opening hours.Grow
posts:readThe posts you write on to.co, drafts included.Pro
posts:writeWrite, save, publish, unpublish and delete posts.Grow

נתיבים

כל נתיב נמצא תחת כתובת הבסיס, עם כתובת ה-to.co של החברה שלכם במקום {host}, למשל 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}/servicesThe services, in order.company:read
GET /v1/orgs/{host}/locationsThe locations, with phones and opening hours.company:read
GET /v1/orgs/{host}/messagesContact 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}/servicesReplace 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}/postsPosts 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}/postsA 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}/publishPublish the If-Match version. It is checked first, as when the owner publishes.posts:write
POST /v1/orgs/{host}/posts/{id}/unpublishTake a post off the page and back to a draft.posts:write

קרדיטים ומגבלות

  • כל בקשה משתמשת בקרדיט API אחד, מאותה מכסה חודשית כמו הקריאות של עוזר ה-AI שלכם לשרת ה-MCP של העסק שלכם: 5,000 בחודש לחברה ב-Pro ו-50,000 ב-Grow. בקשה שנכשלת מחזירה את הקרדיט שלה. הקרדיטים מתחדשים ב-1 בכל חודש (UTC), ואין חיובים על חריגה. התשובות כוללות X-Credits-Limit,‏ X-Credits-Remaining ו-X-Credits-Reset.
  • עד 120 בקשות בדקה לכל מפתח.
  • עד 60 שינויים בדקה לכל חברה, יחד עם שינויים שבוצעו ב-my.to.co ודרך MCP.

שגיאות

שגיאה עונה עם סטטוס HTTP ו-JSON: error (הודעה), code (אחד מהקודים שלמטה) ו-request_id. תשובת 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.

Webhooks

ב-Grow, to.co יכול גם לשלוח אירועים חתומים לשרת שלכם כשמשהו משתנה, כמו הודעה חדשה או שינוי בפרטי החברה שלכם. אפשר להגדיר אותם ב-my.to.co תחת Webhooks.

השלבים הבאים

שפה

בחירה מתוך השפות שהאתר והאפליקציה תומכים בהן במלואן.