openapi: 3.1.0
info:
  title: Symphon API
  version: 1.0.0
  summary: "Connect an e-shop to Symphon: products, stock and the review of new products."
  description: |
    The Symphon API connects an e-shop to one company in Symphon. The e-shop sends its
    products; Symphon checks each one against the company's catalog and keeps its stock, and
    the e-shop reads back the stock Symphon keeps for each product.

    ## What v1 covers today
    Live since 30 November 2026:
    - `GET /me`: check the key and the connection's settings.
    - `PUT /products`: create, update and link products, up to 250 per call.
    - `GET /products` and `GET /products/{external_id}`: products with their stock and price.
    - `DELETE /products/{external_id}`: unlink a product from your store.
    - `GET /product-reviews` and `GET /product-reviews/{external_id}`: the decisions on
      products that waited for review.

    Coming next: orders and their progress (invoice or receipt with its myDATA MARK, courier
    voucher, tracking), stock sent by the e-shop, a separate stock list and webhooks. Until
    they are released, their addresses answer `501 not_available_yet`, so read stock from
    `GET /products`.

    ## Getting started
    1. **Check the key.** Call `GET /me` with `Authorization: Bearer <key>`. The answer
       gives the company, the store, `mode` (`test` or `live`), who keeps the stock
       (`stock_master`) and your limits. Keep the key on the e-shop's server only, never in
       browser code.
    2. **Send the catalog.** `PUT /products` with up to 250 products per call, one call at a
       time. Give every product its `updated_at` from the e-shop, so an old retry never
       overwrites a newer change, and its `quantity`, which becomes its opening stock in
       Symphon. During the initial import every new product answers `pending_review`: this
       is expected, not an error. Keep every `failed` with its `errors` and fix the data in
       the e-shop.
    3. **Follow the review.** Symphon approves the safe products in bulk and decides the
       doubtful ones one by one. Every 15 minutes, call
       `GET /product-reviews?updated_since=<last updated_at>`: keep the `symphon_id` of each
       `approved` product and show the `rejection_reason` of each `rejected` one to the
       e-shop's administrator.
    4. **Day to day, from the e-shop.** When products change, send `PUT /products` with only
       the products that changed. A full send at night is safe: what did not change answers
       `unchanged`. A product removed from the e-shop: `DELETE /products/{external_id}`.
    5. **Day to day, stock and prices from Symphon.** Read the whole list once, then every 5
       to 15 minutes `GET /products?updated_since=…` with the largest `updated_at` you have,
       minus 2 minutes. Update in the e-shop only the products whose `stock.available`
       differs from yours.
    6. **From test to live.** Steps 1 to 3 run first with a `sym_test_` key, then Symphon
       gives the `sym_live_` key and the initial import starts again in the real company.
       Do not mix the `symphon_id` of the test company with the live ones: they are other
       products.

    On `429`, wait as long as `Retry-After` says and go on. On `500`, send the same call
    again: every `PUT` is safe to repeat.

    ## Conventions
    - JSON over HTTPS, UTF-8. Send `Content-Type: application/json`.
    - Money is a number in EUR with up to 2 decimals (`129.90`). Selling prices **include VAT**;
      `cost` is **net of VAT**.
    - Timestamps are ISO 8601 with an offset (`2026-11-24T10:15:00+02:00`).
    - `external_id` is your own id for a product or variant: a string of 1 to 64
      characters from `A-Z a-z 0-9 . _ : / -`. Symphon ids are returned as `symphon_id` (UUID).
    - **Partial updates.** A field you leave out keeps its current value. Only an explicit `null`
      clears a field (where the field allows it). A field Symphon does not know is ignored and
      reported in `warnings` (`unknown_field`).
    - **Safe retries.** Every write is a `PUT` keyed by your `external_id`, so a retry after a
      timeout creates nothing twice.
    - Every response carries `X-Request-Id`. Please include it when you contact support.

    ## Versioning
    `/v1` is stable. We may add fields, values, endpoints and event types at any time; please
    ignore what you do not recognise. A change that breaks existing calls ships as `/v2`, and
    `/v1` keeps working for at least 6 months after `/v2` is released.

    ## Test mode
    Keys starting `sym_test_` work only on a test company that Symphon creates for you. They
    behave like live keys, but nothing reaches myDATA, couriers, marketplaces or customers.

    ## Limits
    - 120 requests per minute per key. Over the limit you get `429` with `Retry-After` (seconds).
      Every response carries `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset`.
    - Request body up to 5 MB. Up to 250 products per call.

    ## Support
    Write to info@symphon.gr with the `X-Request-Id` of the call. Symphon sets up the
    connection and its keys for the company; a company's own users never handle keys.
  contact:
    name: Symphon
    email: info@symphon.gr
    url: https://symphon.gr
servers:
  - url: https://api.symphon.gr/v1
    description: Live and test (the key decides which company you reach)
security:
  - apiKey: []
tags:
  - name: Connection
  - name: Products
paths:
  /me:
    get:
      tags:
        - Connection
      operationId: getMe
      summary: Check the key and see what it can do
      responses:
        "200":
          description: The connection behind this key.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Me"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
  /products:
    put:
      tags:
        - Products
      operationId: upsertProducts
      summary: Create or update up to 250 products
      description: |
        Each product is matched by `external_id` within your store. The call succeeds as a whole
        (`200`) and reports a result for every product; a product with errors is not written, the
        others are.

        **Products already linked to your store** are updated at once (`updated` or `unchanged`).
        A linked product (`content_owner: symphon`) keeps Symphon's title, description, photos,
        brand, category, price, cost and status, and you read them with `GET`; a product your
        store created (`content_owner: eshop`) follows the fields you send. An `ean` that clashes
        with another product of the company is not applied: the result carries the warning
        `ean_in_use` and Symphon keeps the code to check it.

        **A product new to your store** is looked for in the company's catalog in Symphon, then
        either passes on its own or waits for review in Symphon (`pending_review`):
        - linked on its own (`linked`) when its valid `ean` belongs to exactly one Symphon product,
          or when the same `brand` and the same unique `mpn` match one product without an EAN
          clash. Leading zeros of the EAN, case and outer spaces of the MPN and brand do not matter;
        - created on its own (`created`) when nothing in the catalog could be the same product;
        - waits for review when the match is doubtful: the same MPN without a brand or with
          another brand, an EAN to check, several possible products, two of your products with the
          same EAN, or different valid EANs with the same MPN. `review.reasons` says why.

        During the initial catalog import every new product waits, and Symphon approves the
        safe ones in bulk. After it, the company decides whether new products and safe matches
        pass on their own or wait. A product that waits is not in the catalog yet:
        `GET /products/{external_id}` answers `404`, and `GET /product-reviews` returns the decision,
        `approved` with its `symphon_id` or `rejected` with the reason. A rejected product sent
        again unchanged stays `rejected`; sent with changes, it is checked again. There is no
        preview call: `dry_run` answers `400`.

        `title`, `price` and at least one of `ean` or `mpn` are required for a new product; without
        them it is `failed` at once. The price is the product's one price on every channel. For a
        product to be listed on marketplaces, Symphon also needs `category`, `brand`, `cost` and
        `url`. An `ean` that is not a valid GTIN carries the warning `ean_needs_check` and is
        not used as an EAN; Symphon keeps the code to check it.

        A product that sends `updated_at` older than the last one Symphon applied gets
        `ignored_older` and is not written, so a late retry cannot undo a newer change.

        Types as an e-shop's JSON encoder writes them are accepted:
        - `external_id`, `parent_external_id`, `sku` and `mpn` may come as a whole number of up to
          15 digits, read as its digits: `10234` and `"10234"` are the same product. A decimal, a
          negative number or a longer one is `failed`; a code with leading zeros goes as a string,
          since a number has none.
        - `price`, `offer_price`, `cost`, `weight_kg` and `lead_time_days` may come as text with a
          dot for decimals, such as `"54.90"`. A comma (`"54,90"`), a thousands separator or a
          currency sign is `failed`, so `"1,234"` is never read as 1.234.
        - `quantity` may come as a whole number or as text such as `"12"`. It never makes a product
          fail: a value that is not a whole number is ignored with the warning `quantity_ignored`,
          and one below 0 counts as 0 (`quantity_below_zero`).

        Opening stock. Where Symphon keeps the stock (`Me.stock_master` is `symphon`), `quantity`
        is taken once, as the opening stock of a product your store brings to Symphon: when Symphon
        creates it, or on a later send while Symphon still keeps no stock for it (when the first
        sends had no valid `quantity`). The result's `opening_stock` gives the units taken; 0 is
        taken too. From then on Symphon keeps the stock: it moves with the sales of the other
        channels and with goods received, and `GET /products` returns it. Sales in your store will
        lower it through `/orders`, which is not available yet. `quantity` in later sends is
        ignored with the warning `quantity_ignored`. A product the company already had in
        Symphon (`linked`) takes `quantity` only when it is linked and Symphon has no units of it
        (see the next paragraph); otherwise it keeps Symphon's stock. In a shared warehouse the
        units go on the warehouse's shelf for the product's code (its EAN, or its MPN with its
        brand), unless the warehouse already counts that code. A product that waits for review
        takes the `quantity` of the last send when it is approved (warning `quantity_on_approval`).

        Linking to a product Symphon already had. In a group of companies, a product only the
        group's other company has is copied to yours and linked (`linked`); the copy takes your
        `price`. A product archived in Symphon can be linked too: a company can have Symphon
        archive its products when their stock reaches 0, so many of them may be archived. When a copy, an archived
        product or an active one is linked and Symphon has no units of it, it takes your
        `quantity` and `cost`, and `opening_stock` gives the units; an active product sold on
        order with no stock on purpose takes neither. An active product stays active, with
        Symphon's price. An archived product becomes active again when `quantity` is above 0 and
        it now has units (warning `reactivated`); otherwise it stays archived (`archived_in_symphon`). This
        happens only when the product is linked: a product already linked, or linked again after
        `DELETE`, keeps Symphon's stock, cost and status.

        In a shared warehouse a new product needs the warehouse's code, a valid `ean` or an `mpn`
        with its `brand`. Without one it waits for review (`no_stock_key`) and is approved only
        once it has one, so send the `brand` with the `mpn`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - products
              properties:
                products:
                  type: array
                  minItems: 1
                  maxItems: 250
                  items:
                    $ref: "#/components/schemas/ProductInput"
            example:
              products:
                - external_id: P-10234
                  sku: KTS-24
                  ean: "5201234567894"
                  mpn: "62824"
                  title: Κατσαρόλα Inox 24 cm 8,4 lt
                  description: <p>Επαγγελματική κατσαρόλα από ανοξείδωτο χάλυβα 18/10.</p>
                  brand: Example Brand
                  category: Εξοπλισμός κουζίνας > Σκεύη > Κατσαρόλες
                  price: 54.9
                  cost: 26.1
                  availability: on_order
                  lead_time_days: 4
                  images:
                    - https://eshop.example.gr/images/products/62824-1.jpg
                    - https://eshop.example.gr/images/products/62824-2.jpg
                  url: https://eshop.example.gr/katsarola-inox-24
                  weight_kg: 2.4
                  status: active
                  updated_at: 2026-11-24T10:15:00+02:00
      responses:
        "200":
          description: One result per product, in the order sent.
          content:
            application/json:
              schema:
                type: object
                required:
                  - results
                properties:
                  results:
                    type: array
                    items:
                      $ref: "#/components/schemas/ProductResult"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "413":
          $ref: "#/components/responses/TooLarge"
        "429":
          $ref: "#/components/responses/TooManyRequests"
    get:
      tags:
        - Products
      operationId: listProducts
      summary: List products
      description: |
        The store's products in Symphon's catalog, oldest change first. A product's `updated_at`
        moves when the product changes, when its stock changes (quantity, held-back units, or
        the shared warehouse's units of its EAN, or of its MPN and brand) and when it is linked to
        your e-shop (at once, on a review's approval, or again after a DELETE), so polling with
        `updated_since` set to the last `updated_at` you stored picks up stock changes and newly
        linked products too.
      parameters:
        - $ref: "#/components/parameters/UpdatedSince"
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/Limit"
        - name: status
          in: query
          schema:
            type: string
            enum:
              - active
              - draft
              - archived
      responses:
        "200":
          description: A page of products, oldest change first.
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                  - next_cursor
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Product"
                  next_cursor:
                    type:
                      - string
                      - "null"
                    description: Pass as `cursor` for the next page. `null` on the last page.
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
  /products/{external_id}:
    parameters:
      - $ref: "#/components/parameters/ExternalId"
    get:
      tags:
        - Products
      operationId: getProduct
      summary: Get one product as Symphon has it
      responses:
        "200":
          description: The product.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Product"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
    delete:
      tags:
        - Products
      operationId: unlinkProduct
      summary: Unlink a product from your store
      description: |
        Unlinks the product from your store only, whatever its `content_owner`. Symphon's product
        is never archived or deleted, even one your store created: its other sales channels, stock,
        orders, shared warehouse and history stay as they are. Only an authorised user archives a
        product, inside Symphon. In Symphon, the product's sales channels show that it was deleted
        by the e-shop.

        After the call, `GET /products/{external_id}` answers `404` and the product leaves
        `GET /products`. Symphon keeps the link as inactive. Sending the same `external_id` again
        with `PUT /products` links it again to the same Symphon product, with the result `relinked`
        and its earlier `content_owner`, when it is still the same product: the same valid `ean`,
        or, when either side has no valid EAN, the same `mpn` and no other `brand`. Otherwise it is
        matched as a new product. A send with an `updated_at` older than the last one applied
        before the DELETE is `ignored_older`.

        A product that waits for review, or was rejected, leaves the review list: its review is
        cancelled. An approved review stays in `GET /product-reviews` as the record of the decision.

        A repeated DELETE answers `204` again. Only an `external_id` your store never sent answers
        `404`.
      responses:
        "204":
          description: Unlinked, review cancelled, or already unlinked.
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
  /product-reviews:
    get:
      tags:
        - Products
      operationId: listProductReviews
      summary: List the decisions on products that waited for review
      description: |
        Every product of your store that has waited for review in Symphon, with its status:
        `pending`, `approved` (with `symphon_id` and `decision`, `linked` or `created`) or
        `rejected` (with `rejection_reason`). Poll with `updated_since` to pick up new decisions.
        A product removed with `DELETE /products/{external_id}` while it waited leaves this list.
      parameters:
        - $ref: "#/components/parameters/UpdatedSince"
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/Limit"
        - name: status
          in: query
          schema:
            type: string
            enum:
              - pending
              - approved
              - rejected
      responses:
        "200":
          description: A page of reviews, oldest change first.
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                  - next_cursor
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/ProductReview"
                  next_cursor:
                    type:
                      - string
                      - "null"
                    description: Pass as `cursor` for the next page. `null` on the last page.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
  /product-reviews/{external_id}:
    parameters:
      - $ref: "#/components/parameters/ExternalId"
    get:
      tags:
        - Products
      operationId: getProductReview
      summary: Get the review of one product
      responses:
        "200":
          description: The review.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductReview"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
components:
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: |
        `Authorization: Bearer sym_live_…` (or `sym_test_…`). Symphon creates the key when it sets
        up the connection with the e-shop's developer, and it is shown once. One key belongs to one
        store and has its own permissions.
  parameters:
    ExternalId:
      name: external_id
      in: path
      required: true
      schema:
        $ref: "#/components/schemas/ExternalId"
    UpdatedSince:
      name: updated_since
      in: query
      description: |
        An ISO 8601 date-time, such as `2026-11-30T08:15:00Z` or `2026-11-30T08:15:00.000000Z`.
        Send it in UTC with `Z`, or URL-encode it: a raw `+` in a query string reads as a space,
        so `+02:00` must go as `%2B02:00`, or the call is refused with 400.
      schema:
        type: string
        format: date-time
    Cursor:
      name: cursor
      in: query
      schema:
        type: string
    Limit:
      name: limit
      in: query
      schema:
        type: integer
        minimum: 1
        maximum: 500
        default: 100
  responses:
    BadRequest:
      description: The body is not valid JSON or misses required fields.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
    Unauthorized:
      description: Missing, unknown or revoked key.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
    Forbidden:
      description: The key lacks the permission, or the company's plan does not include the API.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
    NotFound:
      description: Nothing with this `external_id` in this store.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
    TooLarge:
      description: More than 250 products, or a body over 5 MB.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
    TooManyRequests:
      description: Over 120 requests per minute. Wait `Retry-After` seconds.
      headers:
        Retry-After:
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
  schemas:
    ExternalId:
      type: string
      minLength: 1
      maxLength: 64
      pattern: ^[A-Za-z0-9._:/-]+$
    Money:
      type: number
      minimum: 0
      multipleOf: 0.01
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - request_id
          properties:
            code:
              type: string
              description: |
                Stable, machine-readable. The key: `missing_key`, `invalid_key`, `key_revoked`,
                `store_inactive`, `plan_without_api`, `missing_permission`. The call:
                `invalid_json`, `validation_failed`, `body_too_large`, `not_found`,
                `method_not_allowed`, `not_available_yet`, `rate_limited`. On our side: `internal_error`.
            message:
              type: string
              description: Human-readable, in English.
            request_id:
              type: string
            details:
              type: array
              description: |
                With `validation_failed` of the query parameters, every problem of the call at once:
                `invalid_format` (`updated_since` is not an ISO 8601 date-time), `invalid_cursor` (not
                a cursor Symphon returned), `out_of_range` (`limit` is not a whole number from 1 to
                500), `invalid_value` (`status` is not one of the listed values), `not_supported`
                (`dry_run` on `PUT /products`, no longer available).
              items:
                $ref: "#/components/schemas/FieldError"
    FieldError:
      type: object
      required:
        - field
        - code
        - message
      properties:
        field:
          type: string
          examples:
            - products[3].ean
        code:
          type: string
          examples:
            - ean_needs_check
          description: |
            Product errors include `missing_title`, `missing_price`, `missing_ean_or_mpn`,
            `invalid_external_id`, `plan_product_limit` and `write_failed`. A doubtful match is not
            an error: the product is `pending_review` with its reasons. Warnings include `ean_needs_check`, `ean_in_use` (another
            Symphon product has this EAN, so it was not given to yours), `symphon_keeps_content`,
            `archived_in_symphon` (the product is archived in Symphon and stays archived, so `status`
            was not applied), `reactivated` (the product was archived in Symphon and was linked with
            stock, so it is active again), `quantity_ignored`, `quantity_below_zero`,
            `quantity_on_approval`, `unknown_field`.
        message:
          type: string
    Me:
      type: object
      required:
        - company
        - store
        - mode
        - permissions
        - stock_master
        - limits
      properties:
        company:
          type: object
          properties:
            symphon_id:
              type: string
              format: uuid
            name:
              type: string
        store:
          type: object
          properties:
            symphon_id:
              type: string
              format: uuid
            name:
              type: string
        mode:
          type: string
          enum:
            - live
            - test
        permissions:
          type: array
          items:
            type: string
            enum:
              - products:read
              - products:write
              - inventory:read
              - inventory:write
              - orders:read
              - orders:write
              - webhooks:manage
              - costs:read
        stock_master:
          type: string
          enum:
            - symphon
            - eshop
          description: Who keeps the stock for this connection. Set by Symphon with the company.
        price_push:
          type: boolean
          description: Whether Symphon will send price changes (for example from its Price Agent) back to the e-shop. Not available yet in v1; read `price` with `GET /products`.
        limits:
          type: object
          properties:
            requests_per_minute:
              type: integer
              examples:
                - 120
            products_per_call:
              type: integer
              examples:
                - 250
            store_products_max:
              type:
                - integer
                - "null"
              description: |
                Product limit of the company's plan, counted across all its stores. `null`: no limit.
                A new product above it is `failed` with `plan_product_limit`.
    ProductCommon:
      type: object
      required:
        - external_id
      properties:
        external_id:
          $ref: "#/components/schemas/ExternalId"
        parent_external_id:
          description: For a variant (size, colour), the `external_id` of its parent product. Every variant is sent as its own product.
          anyOf:
            - $ref: "#/components/schemas/ExternalId"
            - type: "null"
        sku:
          type:
            - string
            - "null"
          maxLength: 100
        ean:
          type:
            - string
            - "null"
          description: |
            GTIN of 8 to 14 digits with a valid check digit; spaces, dashes and dots are dropped,
            and a 9 to 11 digit code gets back the leading zeros it lost (13 digits). Send it as a
            string. A code that fails the check does not refuse the product (warning
            `ean_needs_check`). A product needs `ean` or `mpn`.
        mpn:
          type:
            - string
            - "null"
          maxLength: 100
          description: The manufacturer's (factory) code, not your internal code. Enough on its own when the product has no EAN.
        title:
          type: string
          minLength: 1
          maxLength: 255
          description: Required on create.
        description:
          type:
            - string
            - "null"
          maxLength: 100000
          description: HTML. Allowed tags p, br, strong, b, em, i, u, ul, ol, li, h2, h3, h4, table, thead, tbody, tr, th, td, a (href only). Everything else is removed.
        brand:
          type:
            - string
            - "null"
          maxLength: 120
        category:
          type: string
          minLength: 1
          maxLength: 500
          description: Full path with ` > ` between levels. Once set it can be changed but not cleared.
        price:
          allOf:
            - $ref: "#/components/schemas/Money"
          description: Selling price with VAT. Required on create, greater than 0.
        offer_price:
          description: Sale price with VAT, lower than `price`. `null` ends the offer.
          anyOf:
            - $ref: "#/components/schemas/Money"
            - type: "null"
        cost:
          description: Purchase cost per unit, net of VAT. Once Symphon records receipts for the product, its own weighted average cost takes over.
          anyOf:
            - $ref: "#/components/schemas/Money"
            - type: "null"
        availability:
          type: string
          enum:
            - in_stock
            - on_order
          description: "`on_order` = not held in stock, ordered from the supplier after the sale."
        lead_time_days:
          type:
            - integer
            - "null"
          minimum: 0
          maximum: 60
          description: Days until dispatch for `on_order` products.
        images:
          type: array
          maxItems: 20
          items:
            type: string
            format: uri
            pattern: ^https://
          description: The first image is the main one. Sending the array replaces the previous one.
        url:
          type:
            - string
            - "null"
          format: uri
          description: The product page in the e-shop, used as the link in marketplace feeds.
        weight_kg:
          type:
            - number
            - "null"
          minimum: 0
    ProductInput:
      allOf:
        - $ref: "#/components/schemas/ProductCommon"
        - type: object
          properties:
            quantity:
              description: |
                Your stock of the product, a whole number (text such as `"12"` too). Where Symphon
                keeps the stock, it is taken once, as the opening stock of a product your store
                brings to Symphon, or of a product Symphon had with no units when it is linked
                (see `PUT /products`), and ignored after that; with
                `stock_master: eshop` stock will go through `PUT /inventory`, not available yet. It never makes the
                product fail: a value that is not a whole number is ignored (`quantity_ignored`),
                one below 0 counts as 0 (`quantity_below_zero`).
            status:
              type: string
              enum:
                - active
                - draft
              default: active
              description: |
                Applied only to a product your store created. A product archived in Symphon stays
                archived: `status` is not applied and the warning `archived_in_symphon` says so.
                Only Symphon archives a product. It becomes active again only when it is linked to
                yours with stock (see `PUT /products`); `DELETE` unlinks it.
            updated_at:
              type: string
              format: date-time
              description: When the product last changed in the e-shop. An update older than the last one Symphon applied is ignored.
    ProductResult:
      type: object
      required:
        - external_id
        - status
      properties:
        external_id:
          type: string
        symphon_id:
          type:
            - string
            - "null"
          format: uuid
        status:
          type: string
          enum:
            - created
            - linked
            - relinked
            - updated
            - unchanged
            - pending_review
            - rejected
            - ignored_older
            - failed
          description: |
            `linked`: the company already had this product in Symphon and it is now linked to yours.
            `relinked`: a product you unlinked with `DELETE` is linked again to the same Symphon
            product, and the fields you sent are applied as an update.
            `pending_review`: the product waits for review in Symphon and is not in the catalog yet.
            `rejected`: Symphon rejected this product as you sent it; `review.rejection_reason` says why.
        content_owner:
          type: string
          enum:
            - eshop
            - symphon
          description: "`eshop`: your store created it and its details follow yours. `symphon`: Symphon keeps its details."
        matched_by:
          type: string
          enum:
            - ean
            - mpn
            - review
          description: How a linked product was found. `review`, when a person in Symphon chose the product.
        opening_stock:
          type: integer
          minimum: 0
          description: |
            The units Symphon took from `quantity` in this send as the product's opening stock: for
            a product your store brought to Symphon, or for a copy, an archived or an active product
            linked while Symphon had no units of it. Absent when it took none.
        review:
          type: object
          description: Present with `pending_review` and `rejected`.
          required:
            - status
            - reasons
          properties:
            status:
              type: string
              enum:
                - pending
                - rejected
            reasons:
              type: array
              items:
                $ref: "#/components/schemas/ReviewReason"
            rejection_reason:
              type: string
              maxLength: 500
        errors:
          type: array
          items:
            $ref: "#/components/schemas/FieldError"
        warnings:
          type: array
          items:
            $ref: "#/components/schemas/FieldError"
    ReviewReason:
      type: string
      description: |
        Why a product waits. `initial_import`, `new_product` and `safe_match` wait only for the
        initial import or the company's settings. The others are doubtful and a person decides:
        `multiple_matches` (several Symphon products could be this one), `duplicate_in_eshop`
        (another of your products has the same EAN, or the Symphon product is already linked to
        another of yours), `ean_mpn_conflict` (same MPN, different valid EAN), `mpn_brand_differs`,
        `mpn_without_brand`, `ean_to_check` (the EAN is not a valid GTIN or another product has it),
        `no_stock_key` (in a shared warehouse, a new product with no valid EAN and no MPN with its
        brand; it is approved only once it has one) and `approval_failed` (an approval did not
        complete).
      enum:
        - initial_import
        - new_product
        - safe_match
        - multiple_matches
        - duplicate_in_eshop
        - ean_mpn_conflict
        - mpn_brand_differs
        - mpn_without_brand
        - ean_to_check
        - no_stock_key
        - approval_failed
    ProductReview:
      type: object
      required:
        - external_id
        - status
        - reasons
        - received_at
        - updated_at
      properties:
        external_id:
          type: string
        status:
          type: string
          enum:
            - pending
            - approved
            - rejected
        reasons:
          type: array
          items:
            $ref: "#/components/schemas/ReviewReason"
        decision:
          type: string
          enum:
            - linked
            - created
          description: With `approved`. `linked` to a product the company had, or `created` from yours.
        symphon_id:
          type: string
          format: uuid
          description: With `approved`.
        rejection_reason:
          type: string
          maxLength: 500
          description: With `rejected`.
        received_at:
          type: string
          format: date-time
          description: When the product first waited.
        decided_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    Product:
      allOf:
        - $ref: "#/components/schemas/ProductCommon"
        - type: object
          required:
            - symphon_id
            - created_at
            - updated_at
          properties:
            symphon_id:
              type: string
              format: uuid
            status:
              type: string
              enum:
                - active
                - draft
                - archived
            content_owner:
              type: string
              enum:
                - eshop
                - symphon
            matched_by:
              type:
                - string
                - "null"
              enum:
                - ean
                - mpn
                - review
                - null
            stock:
              type: object
              required:
                - quantity
                - held_back
                - available
                - source
              description: |
                Stock as Symphon counts it. For a company that shares a warehouse with another
                company, it is the shared warehouse's units for the product's key: its EAN (leading
                zeros ignored) or, for a product without a valid EAN, its manufacturer code (`mpn`)
                together with its `brand`. These are the same units the marketplace feeds read. A
                product with neither a valid EAN nor an MPN with a brand has no place in the shared
                warehouse: unless it has stock of its own, its `quantity` is 0 and `source` is
                `none`. For any other company it is the product's own stock.
              properties:
                quantity:
                  type: integer
                  description: |
                    Units Symphon counts for the product. It can be below 0 for a while, when more
                    units were sold than received; offer `available`, which never is.
                held_back:
                  type: integer
                  description: Units kept back in Symphon, not offered for sale.
                available:
                  type: integer
                  description: "`quantity` minus `held_back`, never below 0: what the e-shop may sell."
                source:
                  type: string
                  enum:
                    - shared_warehouse
                    - own
                    - none
                  description: |
                    `shared_warehouse`, `own` or `none`: where `quantity` comes from. `none` means
                    Symphon keeps no stock for this product, so 0 does not mean sold out.
            cost:
              description: Returned only to keys with `costs:read`.
              anyOf:
                - $ref: "#/components/schemas/Money"
                - type: "null"
            created_at:
              type: string
              format: date-time
            updated_at:
              type: string
              format: date-time
              description: The latest of the product's last change, its stock's last change and the time it was linked to your e-shop.
