> For the complete documentation index, see [llms.txt](https://apidocs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.akinon.com/commerce-openapis/admin/product-priority/create-a-product-priority.md).

# Create a product priority

Creates a priority record for a product.

`product` is required. `priority` defaults to `0` when omitted. Because a product may have only one priority record, a product that already has one is rejected with a validation error.

The new priority reaches storefront search after the next incremental index update.

```json
{"openapi":"3.1.0","info":{"title":"Admin API","version":"1.0.0"},"tags":[{"name":"Product Priority","description":"Administrative endpoints for **product priority** — a non-negative ranking weight attached to a product. Storefront listings and search use it to rank products: on the default sort option, products that tie on the primary sort criterion are ordered by priority, highest first.\n\nThere is at most one priority record per product (`product` is a one-to-one reference). A product without a record counts as priority `0`.\n\n## How Priority Affects Ranking\n\nA listing entry can contain more than one product — for example a variant shown together with its sibling variants. The entry is ranked by the **highest priority among the products it contains**. A product is contained in the entry only while it has stock and an image; when `PRODUCT_STOCK_OUT_VISIBILITY_ENABLED` is on, out-of-stock products are contained as well.\n\n| Listing entry | Priority used for ranking |\n|---------------|---------------------------|\n| Simple product without variants | The product's own record. |\n| Variant listed together with its sibling variants (siblings share the listed variant's values for the attribute set's variant-listable attributes, e.g. colour) | The highest record among the listed variant and those siblings. |\n| Variant whose attribute set has no variant-listable attribute | The variant's own record. When `LIST_SIMPLE_INSTEAD_OF_META` is on, the highest record among all variants of the same configurable product. |\n| Configurable (meta) product | The highest record among its variants. The meta product's own record has no effect. |\n| Grouped product | The grouped product's own record. The records of its member products have no effect. |\n\n## Core Capabilities\n\n**1. Listing & Filtering**\n* Retrieve a paginated list of product-priority records.\n* Filter by record identifier (`id`) or by product identifier (`product`).\n* Order results with the `sort` parameter.\n\n**2. Full CRUD**\n* Create a priority record for a product.\n* Retrieve a single record.\n* Fully or partially update a record.\n* Delete a record; the product then counts as priority `0`.\n\n**3. Bulk Upsert**\n* Create or update many records in one request through `POST /product_priority/bulk_upsert/`.\n\n## Product Priority Fields\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `pk` | integer | The unique identifier of the record. Read-only. |\n| `product` | integer | The identifier of the product this priority belongs to. Required. One record per product; the product cannot be changed on update. |\n| `priority` | integer | The ranking weight, from `0` to `2147483647`. Higher values rank the product higher. Defaults to `0` when omitted on create. `null` is not accepted. |\n\n## Filtering & Ordering\n\n| Parameter | Match | Notes |\n|-----------|-------|-------|\n| `id` | Exact | Filter by the record's own identifier. |\n| `product` | Exact | Keep only the record of the given product identifier. |\n\nA non-numeric value, or a `product` that does not exist, is rejected with a `400` validation error. Any other query parameter — including `priority` — is ignored.\n\nResults are returned **ordered by `id` ascending** by default. `sort` accepts `pk`, `product`, and `priority`, each optionally prefixed with `-` for descending order. Any other value is silently ignored and the default ordering applies.\n\n## Validation Rules\n\n* `product` must reference an existing product that does not yet have a priority record. Creating a second record for the same product fails with a `400` validation error — use update or bulk upsert instead.\n* `priority` must be an integer between `0` and `2147483647`.\n* The `product` of an existing record cannot be changed. Sending a different `product` on `PUT` or `PATCH` is rejected with `406 Not Acceptable` and error code `product_priority_700_1`.\n\n## Search Index Synchronization\n\nPriority changes do not update the storefront immediately. They are picked up by the next incremental search-index update, which re-indexes the listing entry of every product whose priority record changed.\n\n> **Important:** A scheduled background job recalculates product scores from recent order data roughly every 5–7 hours and synchronizes them into the product-priority records. For every product that has a computed score, the stored priority is **overwritten** with the score-based value; priority records of products without a computed score are **deleted**. Values written through these endpoints are therefore not permanent — they are replaced on the job's next run.\n\n## Deletion Behavior\n\n`DELETE /product_priority/{id}/` **permanently removes** the priority record; the product itself is untouched. As a side effect, deleting a record refreshes the product's `modified_date` when that timestamp is older than 60 seconds, so the next incremental search-index update picks up the removal and the product counts as priority `0` from then on.\n\n## Dynamic Settings & Environment Variables\n\nNo dynamic settings (`dj_dynamic_settings`) and no environment variables affect these endpoints. Listing, creation, update, bulk upsert, and deletion behave identically regardless of how the platform is configured. `PRODUCT_STOCK_OUT_VISIBILITY_ENABLED` and `LIST_SIMPLE_INSTEAD_OF_META` affect only which products a listing entry contains, and therefore the priority used for ranking (see *How Priority Affects Ranking*)."}],"servers":[{"description":"Omnitron Remote Proxy (external access — recommended)","url":"https://{omnitron_url}/api/v1/remote/{channel_id}","variables":{"omnitron_url":{"default":"sandbox.akinon.com","description":"Omnitron server URL (e.g., {omnitron.akinon.com})"},"channel_id":{"default":"1","description":"The channel identifier the remote request is routed through"}}},{"description":"Commerce API Server (internal / direct access only)","url":"https://{commerce_url}/api/v1","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Internal commerce server URL, reachable only from within the Omnitron network"}}}],"security":[{"tokenAuth":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Token credential sent in the Authorization header, in the form: `Token <your-token>`. Requires a staff (admin) account."}},"schemas":{"ProductPriorityRequest":{"type":"object","description":"The body of a product-priority create request.","required":["product"],"properties":{"product":{"type":"integer","description":"The identifier of an existing product that does not yet have a priority record."},"priority":{"type":"integer","minimum":0,"maximum":2147483647,"default":0,"description":"The ranking weight. Defaults to `0` when omitted."}}},"ProductPriority":{"type":"object","description":"A product-priority record — the ranking weight of a single product.","properties":{"pk":{"type":"integer","readOnly":true,"description":"The unique identifier of the record."},"product":{"type":"integer","description":"The identifier of the product this priority belongs to. One record per product."},"priority":{"type":"integer","minimum":0,"maximum":2147483647,"description":"The ranking weight. Higher values rank the product higher."}}},"ValidationError":{"type":"object","description":"Returned when the request contains invalid or missing data. Errors are grouped by the field they apply to: each key is the name of a field from the request and its value is a list of one or more messages describing what is wrong with that field. Messages that do not belong to any single field are grouped under `non_field_errors`.","properties":{"non_field_errors":{"type":"array","description":"Error messages that apply to the request as a whole rather than to a specific field.","items":{"type":"string"}}},"additionalProperties":{"type":"array","description":"The list of error messages for the field named by the key.","items":{"type":"string"}}},"Error":{"type":"object","description":"An error response.","properties":{"detail":{"type":"string","description":"A human-readable description of the error."}},"additionalProperties":true}},"responses":{"ProductPriorityValidationError":{"description":"The request contains invalid or missing data — for example a missing `product`, a `product` that does not exist or already has a priority record, or a `priority` that is negative, too large, or `null`. The response names the field the complaint belongs to.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}}},"Unauthorized":{"description":"Authentication credentials were not provided or are invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Forbidden":{"description":"The authenticated user does not have administrator privileges.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/product_priority/":{"post":{"tags":["Product Priority"],"operationId":"createProductPriority","summary":"Create a product priority","description":"Creates a priority record for a product.\n\n`product` is required. `priority` defaults to `0` when omitted. Because a product may have only one priority record, a product that already has one is rejected with a validation error.\n\nThe new priority reaches storefront search after the next incremental index update.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProductPriorityRequest"}}}},"responses":{"201":{"description":"The created product-priority record.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProductPriority"}}}},"400":{"$ref":"#/components/responses/ProductPriorityValidationError"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://apidocs.akinon.com/commerce-openapis/admin/product-priority/create-a-product-priority.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
