OsonTopshir API
Loyiha holati: Hamkor API ishga tushirilmoqda. Quyidagi shartnoma (kontrakt) yakuniy v1 ko'rinishida, lekin kalitlar hozircha faqat tanlangan hamkorlarga beriladi.

Buyurtmalar

Buyurtma — bitta hujjatni tayyorlash so'rovi. U yaratiladi, fonda bajariladi va natijada bir yoki bir nechta fayl hosil bo'ladi.

Buyurtma obyekti

idstring

Noyob identifikator, ord_ bilan boshlanadi.

servicestring

Xizmat kaliti: kurs_ishi, taqdimot va hokazo.

statusstring

queued (navbatda), processing (tayyorlanmoqda), succeeded (tayyor), failed (xato, kredit qaytarilgan), canceled (bekor qilingan, kredit qaytarilgan).

credits_chargedinteger

Yechilgan kreditlar. Muvaffaqiyatsiz buyurtmada qaytariladi, lekin maydon o'zgarmaydi; qaytarilganini refunded ko'rsatadi.

refundedboolean

Kredit qaytarilganmi.

resultobject | null

Faqat succeeded holatida to'ladi. Ichida files massivi bor (Fayllar).

errorobject | null

Faqat failed holatida: code va message.

metadataobject

O'zingiz yuborgan kalit-qiymat juftliklari. Webhook va javoblarda qaytadi.

created_atstring

ISO 8601, UTC.

Buyurtma yaratish

POST/v1/orders

Yangi buyurtma yaratadi va 1 kreditni yechadi. Javob 202 Accepted. Qayta yuborishdan himoyalanish uchun Idempotency-Key sarlavhasini yuboring.

servicestringmajburiy

Xizmat kaliti. Ro'yxat.

paramsobjectmajburiy

Xizmatga xos parametrlar. Har bir xizmat sahifasida tavsiflangan.

metadataobjectixtiyoriy

Eng ko'pi bilan 20 ta kalit, qiymat 500 belgigacha.

webhook_urlstringixtiyoriy

Faqat shu buyurtma uchun webhook manzili. Berilmasa, hisob sozlamasidagi manzil ishlatiladi.

curl https://api.osontopshir.uz/partner/v1/orders \
  -H "Authorization: Bearer $OSONTOPSHIR_API_KEY" \
  -H "Idempotency-Key: 1001-v1" \
  -H "Content-Type: application/json" \
  -d '{
    "service": "kurs_ishi",
    "params": {
      "topic": "Korxonada xodimlarni boshqarish tizimi",
      "subject": "Menejment",
      "pages": "30-40",
      "language": "uz"
    },
    "metadata": {"your_order_id": "1001"}
  }'
requests.post(
    "https://api.osontopshir.uz/partner/v1/orders",
    headers={**H, "Idempotency-Key": "1001-v1"},
    json={
        "service": "kurs_ishi",
        "params": {
            "topic": "Korxonada xodimlarni boshqarish tizimi",
            "subject": "Menejment",
            "pages": "30-40",
            "language": "uz",
        },
        "metadata": {"your_order_id": "1001"},
    },
).json()
await (await fetch("https://api.osontopshir.uz/partner/v1/orders", {
  method: "POST",
  headers: { ...H, "Idempotency-Key": "1001-v1", "Content-Type": "application/json" },
  body: JSON.stringify({
    service: "kurs_ishi",
    params: {
      topic: "Korxonada xodimlarni boshqarish tizimi",
      subject: "Menejment",
      pages: "30-40",
      language: "uz",
    },
    metadata: { your_order_id: "1001" },
  }),
})).json();
{
  "id": "ord_8f3a1c9e2b",
  "object": "order",
  "service": "kurs_ishi",
  "status": "queued",
  "credits_charged": 1,
  "refunded": false,
  "result": null,
  "error": null,
  "metadata": {"your_order_id": "1001"},
  "created_at": "2026-10-14T09:30:00Z"
}

Buyurtmani olish

GET/v1/orders/{order_id}

Buyurtmaning joriy holatini qaytaradi. Tayyor bo'lsa, result.files to'ldirilgan bo'ladi.

curl https://api.osontopshir.uz/partner/v1/orders/ord_8f3a1c9e2b \
  -H "Authorization: Bearer $OSONTOPSHIR_API_KEY"
requests.get(
    "https://api.osontopshir.uz/partner/v1/orders/ord_8f3a1c9e2b", headers=H
).json()
await (await fetch(
  "https://api.osontopshir.uz/partner/v1/orders/ord_8f3a1c9e2b", { headers: H }
)).json();
{
  "id": "ord_8f3a1c9e2b",
  "object": "order",
  "service": "kurs_ishi",
  "status": "succeeded",
  "credits_charged": 1,
  "refunded": false,
  "result": {
    "files": [
      {
        "id": "fil_77d0a1",
        "name": "kurs_ishi.docx",
        "content_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
        "size": 412873,
        "url": "https://api.osontopshir.uz/partner/v1/files/fil_77d0a1/content",
        "expires_at": "2026-10-21T09:41:12Z"
      }
    ]
  },
  "error": null,
  "metadata": {"your_order_id": "1001"},
  "created_at": "2026-10-14T09:30:00Z",
  "completed_at": "2026-10-14T09:41:12Z"
}

Buyurtmalar ro'yxati

GET/v1/orders

Yangidan eskiga tartiblangan ro'yxat. Sahifalash kursor orqali.

limitintegerixtiyoriy

1 dan 100 gacha, standart 20.

starting_afterstringixtiyoriy

Oldingi sahifadagi oxirgi buyurtma idsi.

statusstringixtiyoriy

Holat bo'yicha filtr.

servicestringixtiyoriy

Xizmat bo'yicha filtr.

curl "https://api.osontopshir.uz/partner/v1/orders?limit=10&status=succeeded" \
  -H "Authorization: Bearer $OSONTOPSHIR_API_KEY"
requests.get(
    "https://api.osontopshir.uz/partner/v1/orders",
    headers=H, params={"limit": 10, "status": "succeeded"},
).json()
await (await fetch(
  "https://api.osontopshir.uz/partner/v1/orders?limit=10&status=succeeded",
  { headers: H }
)).json();
{
  "object": "list",
  "data": [ { "id": "ord_8f3a1c9e2b", "status": "succeeded" } ],
  "has_more": false
}

Buyurtmani bekor qilish

POST/v1/orders/{order_id}/cancel

Faqat queued holatidagi buyurtmani bekor qilish mumkin. Kredit qaytariladi. Allaqachon processing bo'lsa, 409 order_not_cancelable qaytadi.

curl -X POST https://api.osontopshir.uz/partner/v1/orders/ord_8f3a1c9e2b/cancel \
  -H "Authorization: Bearer $OSONTOPSHIR_API_KEY"
requests.post(
    "https://api.osontopshir.uz/partner/v1/orders/ord_8f3a1c9e2b/cancel", headers=H
).json()
await (await fetch(
  "https://api.osontopshir.uz/partner/v1/orders/ord_8f3a1c9e2b/cancel",
  { method: "POST", headers: H }
)).json();