{"openapi":"3.1.0","info":{"title":"Hesap SDK","description":"Mijozni ro'yxatdan o'tqazish, shablondan shartnoma tuzish va imzolash.\n\nOqim:\n0. POST /v1/auth/token — appId + appSecret evaziga 1 soatlik token oling.\n1. POST /v1/clients — mijozni ro'yxatdan o'tqazing (idempotent).\n2. POST /v1/contracts — shablondan shartnoma yarating.\n3. POST /v1/contracts/{id}/sign-sessions — imzolash sessiyasini oching.\n4. Javobdagi `url` ni o'z sahifangizda iframe'ga qo'ying.\n5. Natijani iframe `postMessage` yoki webhook orqali oling.\n\nAutentifikatsiya: `Authorization: Bearer <accessToken>`. appId va appSecret\nHesap administratori tomonidan beriladi.\n","version":"1.0"},"servers":[{"url":"https://sdk.hesap.uz","description":"Hesap SDK"}],"security":[{"sdkToken":[]}],"tags":[{"name":"Shartnomalar","description":"Shablondan shartnoma tuzish va imzoga chiqarish"},{"name":"Shablonlar","description":"Ilovaga ruxsat etilgan shartnoma shablonlari"},{"name":"Autentifikatsiya","description":"appId va appSecret bilan access token olish"},{"name":"Mijozlar","description":"Mijozni ro'yxatdan o'tqazish va tekshirish"},{"name":"Imzolash","description":"Imzolash sessiyalari"}],"paths":{"/v1/contracts":{"post":{"tags":["Shartnomalar"],"summary":"Shartnoma yaratish","operationId":"create","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractRequest"}}},"required":true},"responses":{"403":{"description":"Forbidden","content":{"*/*":{"schema":{"type":"object"}}}},"503":{"description":"Service Unavailable","content":{"*/*":{"schema":{"type":"object"}}}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"type":"object"}}}},"404":{"description":"Not Found","content":{"*/*":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized","content":{"*/*":{"schema":{"type":"object"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"type":"object"}}}},"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/CreatedDocumentResponse"}}}}}}},"/v1/contracts/{id}/sign-sessions":{"post":{"tags":["Shartnomalar"],"summary":"Imzolash sessiyasini ochish","description":"Javobdagi `url` ni iframe'ga qo'ying. Sessiya bitta tarafni bir marta imzolashga ruxsat beradi va `expiresAt` dan keyin yaroqsiz bo'ladi.","operationId":"createSignSession","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignSessionRequest"}}},"required":true},"responses":{"403":{"description":"Forbidden","content":{"*/*":{"schema":{"type":"object"}}}},"503":{"description":"Service Unavailable","content":{"*/*":{"schema":{"type":"object"}}}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"type":"object"}}}},"404":{"description":"Not Found","content":{"*/*":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized","content":{"*/*":{"schema":{"type":"object"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"type":"object"}}}},"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/SignSessionResponse"}}}}}}},"/v1/clients":{"post":{"tags":["Mijozlar"],"summary":"Mijozni ro'yxatdan o'tqazish","description":"Idempotent: shu PINFL/STIR bilan mijoz bor bo'lsa yangisi ochilmaydi — mavjudining bo'sh maydonlari to'ldiriladi va o'sha mijoz qaytariladi.","operationId":"register","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClientRequest"}}},"required":true},"responses":{"403":{"description":"Forbidden","content":{"*/*":{"schema":{"type":"object"}}}},"503":{"description":"Service Unavailable","content":{"*/*":{"schema":{"type":"object"}}}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"type":"object"}}}},"404":{"description":"Not Found","content":{"*/*":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized","content":{"*/*":{"schema":{"type":"object"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"type":"object"}}}},"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ClientResponse"}}}}}}},"/v1/auth/token":{"post":{"tags":["Autentifikatsiya"],"summary":"Access token olish","description":"Token 1 soat amal qiladi. Muddati tugashidan oldin yangisini oling; 401 kelsa ham yangi token olib so'rovni takrorlang.","operationId":"token","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenRequest"}}},"required":true},"responses":{"403":{"description":"Forbidden","content":{"*/*":{"schema":{"type":"object"}}}},"503":{"description":"Service Unavailable","content":{"*/*":{"schema":{"type":"object"}}}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"type":"object"}}}},"404":{"description":"Not Found","content":{"*/*":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized","content":{"*/*":{"schema":{"type":"object"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"type":"object"}}}},"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/TokenResponse"}}}}},"security":[]}},"/v1/templates":{"get":{"tags":["Shablonlar"],"summary":"Shablonlar ro'yxati","operationId":"getTemplates","responses":{"403":{"description":"Forbidden","content":{"*/*":{"schema":{"type":"object"}}}},"503":{"description":"Service Unavailable","content":{"*/*":{"schema":{"type":"object"}}}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"type":"object"}}}},"404":{"description":"Not Found","content":{"*/*":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized","content":{"*/*":{"schema":{"type":"object"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"type":"object"}}}},"200":{"description":"OK","content":{"*/*":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/TemplateResponse"}}}}}}}},"/v1/templates/{templateId}/fields":{"get":{"tags":["Shablonlar"],"summary":"Shablon maydonlari — shartnoma `values` massivini to'ldirish uchun","operationId":"getFields","parameters":[{"name":"templateId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"403":{"description":"Forbidden","content":{"*/*":{"schema":{"type":"object"}}}},"503":{"description":"Service Unavailable","content":{"*/*":{"schema":{"type":"object"}}}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"type":"object"}}}},"404":{"description":"Not Found","content":{"*/*":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized","content":{"*/*":{"schema":{"type":"object"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"type":"object"}}}},"200":{"description":"OK","content":{"*/*":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/TemplateFieldResponse"}}}}}}}},"/v1/sign-sessions/{id}":{"get":{"tags":["Imzolash"],"summary":"Sessiya holati: PENDING/SIGNED/REJECTED/EXPIRED","operationId":"getById","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"403":{"description":"Forbidden","content":{"*/*":{"schema":{"type":"object"}}}},"503":{"description":"Service Unavailable","content":{"*/*":{"schema":{"type":"object"}}}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"type":"object"}}}},"404":{"description":"Not Found","content":{"*/*":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized","content":{"*/*":{"schema":{"type":"object"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"type":"object"}}}},"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/SignSessionStatusResponse"}}}}}}},"/v1/contracts/{id}":{"get":{"tags":["Shartnomalar"],"summary":"Shartnoma holati","operationId":"getById_1","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"403":{"description":"Forbidden","content":{"*/*":{"schema":{"type":"object"}}}},"503":{"description":"Service Unavailable","content":{"*/*":{"schema":{"type":"object"}}}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"type":"object"}}}},"404":{"description":"Not Found","content":{"*/*":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized","content":{"*/*":{"schema":{"type":"object"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"type":"object"}}}},"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/DocumentEnrichedResponse"}}}}}}},"/v1/contracts/{id}/pdf":{"get":{"tags":["Shartnomalar"],"summary":"Shartnoma PDF (application/pdf)","operationId":"pdf","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"lang","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"403":{"description":"Forbidden","content":{"*/*":{"schema":{"type":"object"}}}},"503":{"description":"Service Unavailable","content":{"*/*":{"schema":{"type":"object"}}}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"type":"object"}}}},"404":{"description":"Not Found","content":{"*/*":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized","content":{"*/*":{"schema":{"type":"object"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"type":"object"}}}},"200":{"description":"OK"}}}},"/v1/clients/{in}":{"get":{"tags":["Mijozlar"],"summary":"Mijoz ma'lumoti PINFL/STIR bo'yicha","operationId":"getByIn","parameters":[{"name":"in","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"403":{"description":"Forbidden","content":{"*/*":{"schema":{"type":"object"}}}},"503":{"description":"Service Unavailable","content":{"*/*":{"schema":{"type":"object"}}}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"type":"object"}}}},"404":{"description":"Not Found","content":{"*/*":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized","content":{"*/*":{"schema":{"type":"object"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"type":"object"}}}},"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ClientResponse"}}}}}}}},"components":{"schemas":{"ContractProductRequest":{"type":"object","properties":{"name":{"type":"string"},"unit":{"type":"string","enum":["DONA","KG","LITR"]},"price":{"type":"number","format":"double"},"quantity":{"type":"number","format":"double"},"amount":{"type":"number","format":"double"},"deliveryAt":{"type":"string","format":"date-time"},"values":{"type":"object","additionalProperties":{}}}},"ContractRequest":{"type":"object","description":"Shablondan shartnoma yaratish","properties":{"templateId":{"type":"string","format":"uuid","description":"Shablon id — ilovaga ruxsat etilgan bo'lishi shart"},"buyerIn":{"type":"string","description":"Xaridor PINFL/STIR (bo'sh -> ilova egasi)"},"sellerIn":{"type":"string","description":"Sotuvchi PINFL/STIR (bo'sh -> ilova egasi)"},"price":{"type":"number","format":"double","description":"Shartnoma summasi"},"currency":{"type":"string","description":"Valyuta kodi: UZS/USD/RUB","enum":["UZS","USD","RUB"]},"initialPayment":{"type":"number","format":"double","description":"Boshlang'ich to'lov"},"deliveryAt":{"type":"string","format":"date-time","description":"Yetkazib berish sanasi"},"values":{"type":"array","description":"Shablon maydonlari qiymatlari","items":{"$ref":"#/components/schemas/DocumentValueRequest"}},"payments":{"type":"array","description":"To'lov jadvali","items":{"$ref":"#/components/schemas/PaymentItem"}},"witnessIds":{"type":"array","description":"Guvohlar (user id)","items":{"type":"string","format":"uuid"}},"products":{"type":"array","description":"Mahsulotlar","items":{"$ref":"#/components/schemas/ContractProductRequest"}}},"required":["templateId"]},"DocumentValueRequest":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"position":{"type":"integer","format":"int32"},"value":{"type":"string"},"templateId":{"type":"string","format":"uuid"},"templateFieldId":{"type":"string","format":"uuid"},"keyName":{"type":"string"}}},"PaymentItem":{"type":"object","description":"To'lov jadvali qatori","properties":{"amount":{"type":"number","format":"double"},"paymentDate":{"type":"string","format":"date-time"}}},"CreatedDocumentResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid"}}},"SignSessionRequest":{"type":"object","description":"Imzolash sessiyasini ochish","properties":{"signerIn":{"type":"string","description":"Kim imzolaydi — shartnomaning buyerIn yoki sellerIn qiymati"},"lang":{"type":"string","description":"Iframe tili: uz (default) / ru / en"},"redirectUrl":{"type":"string","description":"Imzo qo'yilgach mijoz qaytariladigan manzil"},"parentOrigin":{"type":"string","description":"Iframe joylashgan sahifa origini, masalan https://hamkor.uz — berilsa faqat shu sahifa iframe'ga joylay oladi va postMessage shu manzilga boradi"}},"required":["signerIn"]},"SignSessionResponse":{"type":"object","description":"Imzolash sessiyasi","properties":{"id":{"type":"string","format":"uuid"},"url":{"type":"string","description":"Iframe src — sdk.hesap.uz/sign/{token}"},"method":{"type":"string","description":"Shu taraf uchun talab qilinadigan tasdiqlash turi"},"expiresAt":{"type":"string","format":"date-time","description":"Sessiya amal qilish muddati"},"status":{"type":"string","description":"PENDING/SIGNED/REJECTED/EXPIRED"}}},"ClientRequest":{"type":"object","description":"Mijozni ro'yxatdan o'tqazish","properties":{"in":{"type":"string","description":"Jismoniy shaxs uchun 14 xonali PINFL, yuridik uchun 9 xonali STIR"},"type":{"type":"string","description":"CLIENT (jismoniy, default) yoki COMPANY (yuridik)","enum":["SUPER_ADMIN","ADMIN","CLIENT","COMPANY"]},"firstName":{"type":"string","description":"Ism"},"lastName":{"type":"string","description":"Familiya"},"midName":{"type":"string","description":"Otasining ismi"},"phone":{"type":"string","description":"Telefon — imzolash SMS kodi shu raqamga boradi","example":998901234567},"email":{"type":"string","description":"Email"},"passport":{"type":"string","description":"Pasport seriya va raqami","example":"AA1234567"},"passportIssuedBy":{"type":"string","description":"Pasportni bergan organ"},"passportIssueDate":{"type":"string","description":"Berilgan sana (YYYY-MM-DD)"},"passportExpiryDate":{"type":"string","description":"Amal qilish muddati (YYYY-MM-DD)"},"birthday":{"type":"string","description":"Tug'ilgan sana (YYYY-MM-DD)"},"isMan":{"type":"boolean","description":"Jinsi: true — erkak"},"address":{"type":"string","description":"Manzil"},"legalName":{"type":"string","description":"Yuridik shaxs to'liq nomi (type=COMPANY bo'lsa shart)"}},"required":["in"]},"ClientResponse":{"type":"object","description":"Mijoz","properties":{"id":{"type":"string","format":"uuid","description":"Hesap ichidagi id"},"in":{"type":"string","description":"PINFL yoki STIR"},"firstName":{"type":"string"},"lastName":{"type":"string"},"midName":{"type":"string"},"legalName":{"type":"string","description":"Yuridik shaxs nomi"},"type":{"type":"string","description":"CLIENT yoki COMPANY"},"phone":{"type":"string","description":"Telefon"},"verified":{"type":"boolean","description":"Shaxsi OneID/MyID/E-IMZO orqali tasdiqlanganmi"}}},"TokenRequest":{"type":"object","properties":{"appId":{"type":"string"},"appSecret":{"type":"string"}}},"TokenResponse":{"type":"object","properties":{"accessToken":{"type":"string"},"tokenType":{"type":"string"},"expiresIn":{"type":"integer","format":"int64"}}},"TemplateResponse":{"type":"object","description":"Shartnoma shabloni","properties":{"id":{"type":"string","format":"uuid"},"nameUz":{"type":"string","description":"Nomi (uz)"},"nameRu":{"type":"string","description":"Nomi (ru)"},"nameEn":{"type":"string","description":"Nomi (en)"},"individualVerificationType":{"type":"string","description":"Jismoniy shaxs uchun tasdiqlash turi"},"legalVerificationType":{"type":"string","description":"Yuridik shaxs uchun tasdiqlash turi"},"productEnabled":{"type":"boolean","description":"Mahsulot bo'limi yoqilganmi"},"productRequired":{"type":"boolean","description":"Mahsulot majburiymi"},"paymentScheduleEnabled":{"type":"boolean","description":"To'lov jadvali yoqilganmi"},"witnessCount":{"type":"integer","format":"int32","description":"Talab qilinadigan guvohlar soni"}}},"TemplateFieldResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"parentKey":{"type":"string"},"templateId":{"type":"string","format":"uuid"},"nameUz":{"type":"string"},"nameRu":{"type":"string"},"nameEn":{"type":"string"},"keyName":{"type":"string"},"type":{"type":"string","enum":["LIST","SELECT","MULTISELECT","DATE","INTEGER","DOUBLE","STRING","CHECKBOX","RADIO","DOUBLE_INPUT_DATE","DOUBLE_INPUT_INTEGER","DOUBLE_INPUT_DOUBLE","DOUBLE_INPUT_STRING"]},"position":{"type":"string","enum":["BOTTOM","UNDER","LEFT","RIGHT"]},"productField":{"type":"boolean"},"deleted":{"type":"boolean"},"createdDate":{"type":"string","format":"date-time"},"lastModifiedDate":{"type":"string","format":"date-time"}}},"SignSessionStatusResponse":{"type":"object","description":"Sessiya holati","properties":{"id":{"type":"string","format":"uuid"},"contractId":{"type":"string","format":"uuid"},"signerIn":{"type":"string"},"status":{"type":"string","description":"PENDING/SIGNED/REJECTED/EXPIRED"},"method":{"type":"string"},"expiresAt":{"type":"string","format":"date-time"},"completedAt":{"type":"string","format":"date-time"}}},"ContractProductResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"unit":{"type":"string","enum":["DONA","KG","LITR"]},"price":{"type":"number","format":"double"},"quantity":{"type":"number","format":"double"},"amount":{"type":"number","format":"double"},"deliveryAt":{"type":"string","format":"date-time"},"values":{"type":"object","additionalProperties":{}}}},"DocumentEnrichedResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"buyerUserId":{"type":"string","format":"uuid"},"sellerUserId":{"type":"string","format":"uuid"},"templateId":{"type":"string","format":"uuid"},"number":{"type":"string"},"status":{"type":"string","enum":["CREATED","SIGNED_BY_SELLER","SIGNED_BY_BUYER","ACTIVE","COMPLETED","REJECTED","CANCELLED"]},"purpose":{"type":"string","enum":["CONTRACT","TTN","AKT","FACTURA"]},"buyerStatus":{"type":"string","enum":["PENDING","ACCEPTED","REJECTED","CANCELLED"]},"sellerStatus":{"type":"string","enum":["PENDING","ACCEPTED","REJECTED","CANCELLED"]},"price":{"type":"number","format":"double"},"currency":{"type":"string","enum":["UZS","USD","RUB"]},"currencyId":{"type":"string","format":"uuid"},"initialPayment":{"type":"number","format":"double"},"deliveryAt":{"type":"string","format":"date-time"},"buyerIn":{"type":"string"},"sellerIn":{"type":"string"},"buyer":{"$ref":"#/components/schemas/UserBasicResponse"},"seller":{"$ref":"#/components/schemas/UserBasicResponse"},"template":{"$ref":"#/components/schemas/TemplateBasicResponse"},"values":{"type":"array","items":{"$ref":"#/components/schemas/DocumentValueResponse"}},"products":{"type":"array","items":{"$ref":"#/components/schemas/ContractProductResponse"}},"deleted":{"type":"boolean"},"creatorIn":{"type":"string"},"createdBy":{"$ref":"#/components/schemas/UserBasicResponse"},"createdDate":{"type":"string","format":"date-time"},"lastModifiedDate":{"type":"string","format":"date-time"},"version":{"type":"integer","format":"int64"}}},"DocumentValueResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"position":{"type":"integer","format":"int32"},"value":{"type":"string"},"documentId":{"type":"string","format":"uuid"},"templateId":{"type":"string","format":"uuid"},"templateFieldId":{"type":"string","format":"uuid"},"keyName":{"type":"string"},"deleted":{"type":"boolean"},"createdDate":{"type":"string","format":"date-time"},"lastModifiedDate":{"type":"string","format":"date-time"}}},"TemplateBasicResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"$ref":"#/components/schemas/TextModel"},"sellerName":{"$ref":"#/components/schemas/TextModel"},"buyerName":{"$ref":"#/components/schemas/TextModel"},"exchangeMode":{"type":"string"}}},"TextModel":{"type":"object","properties":{"uz":{"type":"string"},"ru":{"type":"string"},"en":{"type":"string"}}},"UserBasicResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"firstName":{"type":"string"},"lastName":{"type":"string"},"phone":{"type":"string"},"legalName":{"type":"string"},"type":{"type":"string","enum":["SUPER_ADMIN","ADMIN","CLIENT","COMPANY"]}}}},"securitySchemes":{"sdkToken":{"type":"http","description":"POST /v1/auth/token javobidagi accessToken","scheme":"bearer"}}}}