# Prioritized

Sometimes it is necessary to process jobs following a priority order. This is easily achieved by setting the "priority" option on the job payload.

The priorities range from `1` to `2 097 152.` Where the lowest value has the largest priority, following the same schema used by processes in Unix. A job without priority (or priority 0) will have the highest priority and be processed before any other prioritized job.

The JobOpts interface with the added priority option would look like this:

```typescript
interface JobOpts {
  priority: number; // an integer between 1 and 2_097_152
  // ... More opts
}
```

{% tabs %}
{% tab title="Curl" %}

```powershell
curl --location 'http://mydomain.dev/queues/my-queue/jobs' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer my-secret-token' \
--data '[{
	  "name": "paint-red",
          "data": {},
          "opts": {
            "priority": 5
          }
         },
         {
	  "name": "paint-black",
          "data": {}
         } 
]'
```

{% endtab %}
{% endtabs %}

The above snippet will add one Job with priority 5, and another without priority. The job named "paint-black" even though it was added after the one called "paint-red" will be processed before, as jobs without priority will be processed before jobs with priority.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bullmq.net/http-api/queues/adding-jobs/prioritized.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
