# Assign Product to Category

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/products/{product_id}/categories/:
    post:
      summary: Assign Product to Category
      deprecated: false
      description: >-
        Use this endpoint to add a new product to a certain category by
        specifying the product id and providing the category id in the request
        body.


        <Accordion title="🔑Scopes" defaultOpen>
            
          `products.read_write` - Products Read & Write
         
        </Accordion>
      operationId: post-one-product
      tags:
        - Default module/Apps/Merchant APIs/Products/Product Categories
        - Product Categories
      parameters:
        - name: product_id
          in: path
          description: ''
          required: true
          example: a7ad89d0-03e2-430f-b6e4-0624ef05e571
          schema:
            type: string
            examples:
              - 107c2ff5-5c70-4749-b9bd-56dc1793013b
        - name: Authorization
          in: header
          description: >-
            The Authorization token is a unique key given to the third-party
            application (Partner) by Zid. It is used to authenticate the API
            requests made by the Partner application. The token verifies the
            partner's identity and ensures they have permission to access Zid's
            API but does not provide any specific user or store information. It
            should be included in the header of API requests when the partner
            application needs to access Zid's API.
          required: true
          example: '{{Autherization}}'
          schema:
            type: string
        - name: X-Manager-Token
          in: header
          description: >-
            This token is used to authenticate and access information related to
            the store. It is obtained through an OAuth mechanism and is required
            to perform operations on the store's data. The `X-Manager-Token`
            should be included in the header of API requests that require
            store-related information.
          required: true
          example: '{{Access-Token}}'
          schema:
            type: string
        - name: Store-Id
          in: header
          description: ''
          required: true
          example: '{{StoreId}}'
          schema:
            type: number
            examples:
              - 37213
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: integer
                  examples:
                    - 1473477
              x-apidog-orders:
                - id
              x-apidog-ignore-properties: []
            example:
              id: 1473477
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: >-
                      Unique identifier of the category. Returned as a string
                      even if the original ID is numeric.
                    examples:
                      - '1473477'
                  name:
                    type: string
                    description: Category name in the default store language.
                    examples:
                      - test sub
                  slug:
                    type: string
                    description: URL-friendly slug generated for the category.
                    examples:
                      - تصنيف-فرعي
                  description:
                    type: string
                    description: Short description of the category.
                    examples:
                      - Sub category 1
                  cover_image:
                    type: string
                    description: >-
                      Cover image URL for the category. Returns null if no cover
                      image is assigned.
                    examples:
                      - null
                    nullable: true
                  image:
                    type: string
                    description: >-
                      Main image URL of the category. Returns null if no image
                      is assigned.
                    examples:
                      - null
                    nullable: true
                  display_order:
                    type: integer
                    description: >-
                      Display order of the category in category listings. Null
                      means default ordering.
                    examples:
                      - null
                  meta:
                    type: object
                    properties:
                      childs:
                        type: array
                        items:
                          type: string
                        description: List of child categories under this category.
                        examples:
                          - []
                      parents:
                        type: array
                        items:
                          type: string
                        description: List of parent categories for this category.
                        examples:
                          - []
                    required:
                      - childs
                      - parents
                    x-apidog-orders:
                      - childs
                      - parents
                    description: Additional metadata related to category hierarchy.
                    x-apidog-ignore-properties: []
                required:
                  - id
                  - name
                  - slug
                  - description
                  - cover_image
                  - image
                  - display_order
                  - meta
                x-apidog-orders:
                  - id
                  - name
                  - slug
                  - description
                  - cover_image
                  - image
                  - display_order
                  - meta
                title: Assign Product to Category Response
                description: Response returned after assigning a product to a category.
                x-apidog-ignore-properties: []
              example:
                id: '1473477'
                name: test sub
                slug: تصنيف-فرعي
                description: Sub category 1
                cover_image: null
                image: null
                display_order: 0
                meta:
                  childs: []
                  parents: []
          headers: {}
          x-apidog-name: OK
        '401':
          description: ''
          content:
            application/json:
              schema:
                type: object
                description: >-
                  Response returned when the request cannot be authenticated
                  because the required credentials are missing, invalid, or
                  expired.
                properties:
                  status:
                    type: string
                    description: Indicates the overall status of the API response.
                    examples:
                      - error
                  message:
                    type: object
                    description: >-
                      Contains structured details explaining why the request
                      could not be authenticated.
                    properties:
                      type:
                        type: string
                        description: Indicates the category of the response message.
                        examples:
                          - error
                      code:
                        type: string
                        description: >-
                          A machine-readable code identifying the authentication
                          error. Returns null when no specific code is
                          available.
                        examples:
                          - UNAUTHORIZED
                        nullable: true
                      name:
                        type: string
                        description: >-
                          A short, human-readable title describing the
                          authentication error. Returns null when no title is
                          available.
                        examples:
                          - Unauthorized
                        nullable: true
                      description:
                        type: string
                        description: >-
                          A human-readable explanation of why the request could
                          not be authenticated. Returns null when no detailed
                          explanation is available.
                        examples:
                          - >-
                            Authentication credentials are missing, invalid, or
                            expired.
                        nullable: true
                    required:
                      - type
                      - code
                      - name
                      - description
                    x-apidog-orders:
                      - type
                      - code
                      - name
                      - description
                    x-apidog-ignore-properties: []
                required:
                  - status
                  - message
                x-apidog-orders:
                  - status
                  - message
                examples:
                  - status: error
                    message:
                      type: error
                      code: UNAUTHORIZED
                      name: Unauthorized
                      description: >-
                        Authentication credentials are missing, invalid, or
                        expired.
                x-apidog-ignore-properties: []
              examples:
                '2':
                  summary: Example 1
                  value:
                    status: error
                    message:
                      type: error
                      code: ERROR_SESSION_MISSING
                      name: Sorry
                      description: Please login first.
                '3':
                  summary: Example 2
                  value:
                    status: error
                    message:
                      type: error
                      code: ERROR_SESSION_INVALID
                      name: Sorry
                      description: Login session expired. Please login again.
                '4':
                  summary: Example 3
                  value:
                    status: error
                    message:
                      type: error
                      code: ERROR_SESSION_INVALID
                      name: Sorry
                      description: Invalid authentication
          headers: {}
          x-apidog-name: Unauthorized
        '500':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: Status of the error.
                  message:
                    $ref: '#/components/schemas/ResponseEnvelopMessage'
                required:
                  - status
                  - message
                x-apidog-orders:
                  - status
                  - message
                x-apidog-ignore-properties: []
              example:
                status: error
                message:
                  type: error
                  code: MSG_HIDDEN
                  name: Error
                  description: Internal Server Error
          headers: {}
          x-apidog-name: Internal Server error
      security: []
      x-apidog-folder: Default module/Apps/Merchant APIs/Products/Product Categories
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/613905/apis/api-9148597-run
components:
  schemas:
    ResponseEnvelopMessage:
      type: object
      properties:
        type:
          type: string
          description: Type of response message returned by the API.
          examples:
            - success
        code:
          type: string
          description: Response code returned by the API, if available.
          examples:
            - MSG_POPUP_OK
          nullable: true
        name:
          type: string
          description: Name or title of the response message, if available.
          examples:
            - Coupons
          nullable: true
        description:
          type: string
          description: Detailed description of the response message, if available.
          examples:
            - Coupons created successfully
          nullable: true
      required:
        - type
        - code
        - name
        - description
      description: Additional response metadata.
      x-apidog-orders:
        - type
        - code
        - name
        - description
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
  securitySchemes: {}
servers:
  - url: https://api.zid.sa/
    description: Prod Env
security: []

```
