> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.loreos.app/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.loreos.app/_mcp/server.

# Enqueue a research query plan

POST https://api.loreos.app/v1/characters/{slug}/research/query-plans/enqueue
Content-Type: application/json

Reference: https://docs.loreos.app/api-reference/research-and-evidence/enqueue-research-query-plan

## Authentication

- `Authorization` header (bearer token, required) — LoreOS runtime API key (`ck_...`), sent as `Authorization: Bearer <key>`.

## Servers

- `https://api.loreos.app` (Production, default)
- `http://127.0.0.1:8000` (Local development)

## Request

### Path parameters

- `slug` (string, required)

### Body (application/json)

This endpoint expects a ResearchQueryPlanEnqueueRequest.

- `planner_input` (ResearchQueryPlannerInput, required) — The typed research-needs input used to create the query plan. LoreOS revalidates it server-side before enqueueing runs.
- `query_plan` (ResearchQueryPlan, required) — LLM or operator-authored query plan; accepted queries become runs.
- `trigger_source` (enum, optional, default: api)
  - Allowed values: `api`, `story_room`, `scheduler`, `content_intent`, `operator`, `admin`
- `expand_queries` (boolean, optional, default: true) — Whether LoreOS should apply deterministic query expansion before enqueueing runs. Expansion can split valid multi-category place queries; it does not repair invalid queries or call providers.
- `max_expansions_per_query` (integer, optional, default: 3) — Maximum deterministic variants to generate per source query.
- `idempotency_prefix` (string, optional, nullable) — Optional stable prefix. Defaults to app/character/query-plan identifiers.

## Response

### 200

Successful Response

- `map from string to any`

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### ResearchQueryPlannerInput

- `current_date` (date, required)
- `character_id` (string, required)
- `character_name` (string, required)
- `character_profile` (string, required)
- `provider_allowlist` (list of enum, required)
  - Allowed values: `gemini_search_grounding`, `gemini_deep_research`, `gemini_maps_grounding`, `google_places`, `gemini_video_understanding`
- `needs` (list of ResearchNeed, required)
- `scope` (string, optional, default: character_global)
- `world_model_summary` (string, optional, default: )
- `active_arcs` (list of string, optional)
- `mechanism_policy` (map from string to any, optional)
- `max_queries` (integer, optional, default: 5)
- `max_provider_calls` (integer, optional, default: 5)
- `private_context_markers` (list of string, optional)

### ResearchQueryPlan

- `research_plan_id` (string, required)
- `plan_summary` (string, required)
- `queries` (list of ResearchQueryCandidate, optional)
- `blocked_queries` (list of BlockedQuery, optional)

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `input` (any, optional)
- `ctx` (ValidationErrorCtx, optional)

### ResearchNeed

- `need_id` (string, required)
- `source_node` (string, required)
- `need_type` (enum, required)
  - Allowed values: `world_model_expansion`, `place_discovery`, `interest_discovery`, `video_discovery`, `video_analysis`, `deep_topic_research`, `local_texture`, `story_engine_event_source`, `current_fact_grounding`
- `topic` (string, required)
- `reason` (string, required)
- `expected_use` (enum, required)
  - Allowed values: `world_model_candidate`, `story_engine_event_source`, `life_template_candidate`, `weekly_arc_material`, `daily_timetable_texture`, `place_candidate`, `interest_seed_candidate`, `grounded_reply_context`, `mission_candidate`, `social_content_material`
- `allowed_provider_families` (list of string, required)
- `research_phase` (enum, optional, default: atomic_verification)
  - Allowed values: `candidate_discovery`, `atomic_verification`
- `priority` (enum, optional, default: medium)
  - Allowed values: `low`, `medium`, `high`
- `deadline` (enum, optional, default: background)
  - Allowed values: `before_next_daily_cycle`, `before_next_weekly_cycle`, `background`, `on_demand`
- `freshness` (enum, optional, default: evergreen)
  - Allowed values: `current`, `last_7_days`, `last_30_days`, `last_12_months`, `evergreen`
- `location_scope` (string, optional, nullable)
- `language_hint` (string, optional, default: ko)
- `novelty_mode` (enum, optional, default: exploit)
  - Allowed values: `exploit`, `explore`, `bridge`
- `novelty_distance` (integer, optional, default: 0)
- `must_not_include` (list of string, optional)
- `blocked_uses` (list of string, optional)
- `private_context_refs` (list of string, optional)

### ResearchQueryCandidate

- `query_id` (string, required)
- `need_id` (string, required)
- `provider` (enum, required)
  - Allowed values: `gemini_search_grounding`, `gemini_deep_research`, `gemini_maps_grounding`, `google_places`, `gemini_video_understanding`
- `purpose` (string, required)
- `expected_use` (enum, required)
  - Allowed values: `world_model_candidate`, `story_engine_event_source`, `life_template_candidate`, `weekly_arc_material`, `daily_timetable_texture`, `place_candidate`, `interest_seed_candidate`, `grounded_reply_context`, `mission_candidate`, `social_content_material`
- `novelty_mode` (enum, required)
  - Allowed values: `exploit`, `explore`, `bridge`
- `novelty_distance` (integer, required)
- `risk` (enum, required)
  - Allowed values: `low`, `medium`, `high`
- `freshness` (enum, required)
  - Allowed values: `current`, `last_7_days`, `last_30_days`, `last_12_months`, `evergreen`
- `query` (string, optional, nullable)
- `prompt` (string, optional, nullable)
- `url` (string, optional, nullable)
- `latitude` (double, optional, nullable)
- `longitude` (double, optional, nullable)
- `language` (string, optional, default: ko)

### BlockedQuery

- `attempted_query` (string, required)
- `reason_code` (enum, required)
  - Allowed values: `private_user_location`, `hidden_future_plan`, `creator_only_note`, `scope_leakage`, `provider_not_allowed`, `cost_budget_exceeded`, `query_too_broad`, `query_too_specific`, `stale_query`, `policy_boundary`
- `explanation` (string, required)

### ValidationErrorLocItems

### ValidationErrorCtx

## Examples

**Request**

```json
{
  "planner_input": {
    "current_date": "2023-01-15",
    "character_id": "string",
    "character_name": "string",
    "character_profile": "string",
    "provider_allowlist": [
      "gemini_search_grounding"
    ],
    "needs": [
      {
        "need_id": "string",
        "source_node": "string",
        "need_type": "world_model_expansion",
        "topic": "string",
        "reason": "string",
        "expected_use": "world_model_candidate",
        "allowed_provider_families": [
          "string"
        ]
      }
    ]
  },
  "query_plan": {
    "research_plan_id": "string",
    "plan_summary": "string"
  }
}
```

**Response**

```json
{}
```

**SDK Code**

```python
import requests

url = "https://api.loreos.app/v1/characters/slug/research/query-plans/enqueue"

payload = {
    "planner_input": {
        "current_date": "2023-01-15",
        "character_id": "string",
        "character_name": "string",
        "character_profile": "string",
        "provider_allowlist": ["gemini_search_grounding"],
        "needs": [
            {
                "need_id": "string",
                "source_node": "string",
                "need_type": "world_model_expansion",
                "topic": "string",
                "reason": "string",
                "expected_use": "world_model_candidate",
                "allowed_provider_families": ["string"]
            }
        ]
    },
    "query_plan": {
        "research_plan_id": "string",
        "plan_summary": "string"
    }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.loreos.app/v1/characters/slug/research/query-plans/enqueue';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"planner_input":{"current_date":"2023-01-15","character_id":"string","character_name":"string","character_profile":"string","provider_allowlist":["gemini_search_grounding"],"needs":[{"need_id":"string","source_node":"string","need_type":"world_model_expansion","topic":"string","reason":"string","expected_use":"world_model_candidate","allowed_provider_families":["string"]}]},"query_plan":{"research_plan_id":"string","plan_summary":"string"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.loreos.app/v1/characters/slug/research/query-plans/enqueue"

	payload := strings.NewReader("{\n  \"planner_input\": {\n    \"current_date\": \"2023-01-15\",\n    \"character_id\": \"string\",\n    \"character_name\": \"string\",\n    \"character_profile\": \"string\",\n    \"provider_allowlist\": [\n      \"gemini_search_grounding\"\n    ],\n    \"needs\": [\n      {\n        \"need_id\": \"string\",\n        \"source_node\": \"string\",\n        \"need_type\": \"world_model_expansion\",\n        \"topic\": \"string\",\n        \"reason\": \"string\",\n        \"expected_use\": \"world_model_candidate\",\n        \"allowed_provider_families\": [\n          \"string\"\n        ]\n      }\n    ]\n  },\n  \"query_plan\": {\n    \"research_plan_id\": \"string\",\n    \"plan_summary\": \"string\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.loreos.app/v1/characters/slug/research/query-plans/enqueue")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"planner_input\": {\n    \"current_date\": \"2023-01-15\",\n    \"character_id\": \"string\",\n    \"character_name\": \"string\",\n    \"character_profile\": \"string\",\n    \"provider_allowlist\": [\n      \"gemini_search_grounding\"\n    ],\n    \"needs\": [\n      {\n        \"need_id\": \"string\",\n        \"source_node\": \"string\",\n        \"need_type\": \"world_model_expansion\",\n        \"topic\": \"string\",\n        \"reason\": \"string\",\n        \"expected_use\": \"world_model_candidate\",\n        \"allowed_provider_families\": [\n          \"string\"\n        ]\n      }\n    ]\n  },\n  \"query_plan\": {\n    \"research_plan_id\": \"string\",\n    \"plan_summary\": \"string\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.loreos.app/v1/characters/slug/research/query-plans/enqueue")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"planner_input\": {\n    \"current_date\": \"2023-01-15\",\n    \"character_id\": \"string\",\n    \"character_name\": \"string\",\n    \"character_profile\": \"string\",\n    \"provider_allowlist\": [\n      \"gemini_search_grounding\"\n    ],\n    \"needs\": [\n      {\n        \"need_id\": \"string\",\n        \"source_node\": \"string\",\n        \"need_type\": \"world_model_expansion\",\n        \"topic\": \"string\",\n        \"reason\": \"string\",\n        \"expected_use\": \"world_model_candidate\",\n        \"allowed_provider_families\": [\n          \"string\"\n        ]\n      }\n    ]\n  },\n  \"query_plan\": {\n    \"research_plan_id\": \"string\",\n    \"plan_summary\": \"string\"\n  }\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.loreos.app/v1/characters/slug/research/query-plans/enqueue', [
  'body' => '{
  "planner_input": {
    "current_date": "2023-01-15",
    "character_id": "string",
    "character_name": "string",
    "character_profile": "string",
    "provider_allowlist": [
      "gemini_search_grounding"
    ],
    "needs": [
      {
        "need_id": "string",
        "source_node": "string",
        "need_type": "world_model_expansion",
        "topic": "string",
        "reason": "string",
        "expected_use": "world_model_candidate",
        "allowed_provider_families": [
          "string"
        ]
      }
    ]
  },
  "query_plan": {
    "research_plan_id": "string",
    "plan_summary": "string"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.loreos.app/v1/characters/slug/research/query-plans/enqueue");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"planner_input\": {\n    \"current_date\": \"2023-01-15\",\n    \"character_id\": \"string\",\n    \"character_name\": \"string\",\n    \"character_profile\": \"string\",\n    \"provider_allowlist\": [\n      \"gemini_search_grounding\"\n    ],\n    \"needs\": [\n      {\n        \"need_id\": \"string\",\n        \"source_node\": \"string\",\n        \"need_type\": \"world_model_expansion\",\n        \"topic\": \"string\",\n        \"reason\": \"string\",\n        \"expected_use\": \"world_model_candidate\",\n        \"allowed_provider_families\": [\n          \"string\"\n        ]\n      }\n    ]\n  },\n  \"query_plan\": {\n    \"research_plan_id\": \"string\",\n    \"plan_summary\": \"string\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "planner_input": [
    "current_date": "2023-01-15",
    "character_id": "string",
    "character_name": "string",
    "character_profile": "string",
    "provider_allowlist": ["gemini_search_grounding"],
    "needs": [
      [
        "need_id": "string",
        "source_node": "string",
        "need_type": "world_model_expansion",
        "topic": "string",
        "reason": "string",
        "expected_use": "world_model_candidate",
        "allowed_provider_families": ["string"]
      ]
    ]
  ],
  "query_plan": [
    "research_plan_id": "string",
    "plan_summary": "string"
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.loreos.app/v1/characters/slug/research/query-plans/enqueue")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```