Rawi

مرجع API · Settings

Update products, customers & cells

put/settings/products
احراز هویتتوکن مشتری (Bearer)
سطح دسترسیکاربر رایگان · کاربر حرفه‌ای

Customer token (Bearer) — free and paid users

Saves everything at once. Changing a generic name, product type, customer core fields or active cells rebuilds the questions and breaks the trend → 409 unless confirm: true.

بدنه درخواست

فیلدنوعتوضیح
products*object[]1..plan products (free 1, paid 3); same item rules as O4
products[].idinteger | nullUnique ID.
products[].name*string
products[].generic_name*string
products[].type*string ("software", "service", "physical", "other")
products[].featuresarray | null
customers*object[]1..plan customers (free 1, paid 2); same item rules as O5 (industries max 10, decision_makers max 5)
customers[].idinteger | nullUnique ID.
customers[].kind*string ("b2b", "b2c")
customers[].industriesarray | null
customers[].sizesarray | null
customers[].decision_makersarray | null
customers[].country*string
customers[].provincestring | null
customers[].citystring | null
customers[].main_needstring | null
cellsarray | nullmax 12; product_id, target_customer_id, active, position 1–50; active ≤ plan cells
confirmboolean | nulltrue = accept the question rebuild
نمونهjson
{
  "products": [
    {
      "id": {{productId}},
      "name": "آوند ابری",
      "generic_name": "نرم‌افزار حسابداری ابری",
      "type": "software",
      "features": [
        "صدور فاکتور رسمی",
        "اتصال به سامانه مودیان",
        "دسترسی چندکاربره"
      ]
    }
  ],
  "customers": [
    {
      "id": {{customerId}},
      "kind": "b2b",
      "industries": [
        "خدمات",
        "بازرگانی"
      ],
      "sizes": [
        "micro",
        "small"
      ],
      "decision_makers": [
        "مدیر مالی",
        "مدیرعامل"
      ],
      "country": "ایران",
      "province": null,
      "city": null,
      "main_need": "حسابداری ساده و قانونی"
    }
  ],
  "cells": [
    {
      "product_id": {{productId}},
      "target_customer_id": {{customerId}},
      "active": true,
      "position": 1
    }
  ],
  "confirm": false
}

پاسخ‌ها

200 — same as GET 409 body (ConfirmRequired): {"message":"…","requires_confirmation":true,"reason":"rebuild_questions","questions_count":10,"changes":[{"field":"products.0.generic_name","from":"نرم‌افزار حسابداری ابری","to":"نرم‌افزار حسابداری آنلاین"}]}.

فیلدنوعتوضیح
products*object[]
products[].id*integerUnique ID.
products[].name*string
products[].generic_name*string
products[].type*string
products[].features*any[]
products[].position*integer
customers*object[]
customers[].id*integerUnique ID.
customers[].kind*string
customers[].name*string
customers[].industries*any[]
customers[].sizes*any[]
customers[].decision_makers*any[]
customers[].country*string
customers[].province*string | null
customers[].city*string | null
customers[].main_need*string | null
customers[].position*integer
cells*object[]
cells[].id*integerUnique ID.
cells[].product_id*integer
cells[].target_customer_id*integer
cells[].label*string
cells[].active*boolean
cells[].position*integer
limits*any[]Limits of the account's plan.
question_counts*object
json
{
  "…": "GET /settings/products body after saving"
}

401 — Missing/invalid token, or a token of the wrong owner (admin token on a user route or vice versa): {"message":"…","code":"unauthenticated"} (message in the request language)

فیلدنوع
message*string
codestring
json
{
  "message": "Please sign in to continue; your session has ended or is not valid.",
  "code": "unauthenticated"
}

409 — ConfirmRequired — resend with confirm: true

فیلدنوع
messagestring
requires_confirmation*boolean
reasonstring
questions_countinteger
changesobject[]
changes[].fieldstring
changes[].fromany
changes[].toany
json
{
  "message": "",
  "requires_confirmation": true,
  "reason": "",
  "questions_count": 0,
  "changes": [
    {
      "field": "",
      "from": null,
      "to": null
    }
  ]
}

422 — Validation failed (limits (products max, cells max/min), products.N.generic_name contains the brand, unknown ids)

فیلدنوع
message*string
errors*object
json
{
  "message": "",
  "errors": {
    "email": [
      "ایمیل معتبر نیست."
    ]
  }
}

نمونهٔ curl

bash
curl -X PUT 'http://127.0.0.1:8010/api/settings/products' \
  -H 'Accept: application/json' \
  -H "Authorization: Bearer $RAWI_USER_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
  "products": [
    {
      "id": {{productId}},
      "name": "آوند ابری",
      "generic_name": "نرم‌افزار حسابداری ابری",
      "type": "software",
      "features": [
        "صدور فاکتور رسمی",
        "اتصال به سامانه مودیان",
        "دسترسی چندکاربره"
      ]
    }
  ],
  "customers": [
    {
      "id": {{customerId}},
      "kind": "b2b",
      "industries": [
        "خدمات",
        "بازرگانی"
      ],
      "sizes": [
        "micro",
        "small"
      ],
      "decision_makers": [
        "مدیر مالی",
        "مدیرعامل"
      ],
      "country": "ایران",
      "province": null,
      "city": null,
      "main_need": "حسابداری ساده و قانونی"
    }
  ],
  "cells": [
    {
      "product_id": {{productId}},
      "target_customer_id": {{customerId}},
      "active": true,
      "position": 1
    }
  ],
  "confirm": false
}'

امتحان در کنسول