# Run the research scheduler

Source: https://musicnerd-docs.vercel.app/api-reference/research/scheduler

Run the research scheduler

## GET /api/research/advance

Full OpenAPI specification: https://musicnerd-docs.vercel.app/spec/research.json

## Authentication

This operation requires one of the security alternatives in the specification below. Security scheme definitions are included where present in the published specification.

[Authentication guide](https://musicnerd-docs.vercel.app/authentication)

## Operation and referenced schemas

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Music Nerd API: research",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://musicnerd-api.vercel.app",
      "description": "Production"
    },
    {
      "url": "https://musicnerd-api-staging.vercel.app",
      "description": "Staging (staging database)"
    }
  ],
  "paths": {
    "/api/research/advance": {
      "get": {
        "summary": "Run the research scheduler",
        "operationId": "runResearchScheduler",
        "security": [
          {
            "cronSecret": []
          }
        ],
        "description": "The scheduler Vercel Cron calls. Takes slices until its time budget runs out (the function's 60 s limit, less a reserve), skipping jobs that are waiting on an outside run. Requires `Authorization: Bearer <CRON_SECRET>` when the deployment sets `CRON_SECRET`.",
        "responses": {
          "200": {
            "description": "The slices that ran this tick.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "ran",
                    "slices"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok",
                        "error"
                      ]
                    },
                    "ran": {
                      "type": "boolean"
                    },
                    "slices": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "ran": {
                            "type": "boolean",
                            "description": "Whether a slice ran. `false` means nothing was claimable."
                          },
                          "jobId": {
                            "type": "string",
                            "format": "uuid",
                            "description": "The job the slice belonged to."
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "social_ingest",
                              "caption_extract",
                              "lore_refresh",
                              "source_search",
                              "latest_refresh"
                            ],
                            "description": "The job's kind."
                          },
                          "artistId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "progress": {
                            "type": "string",
                            "description": "A short description of what the slice did."
                          },
                          "done": {
                            "type": "boolean",
                            "description": "Whether the job finished with this slice."
                          },
                          "waiting": {
                            "type": "boolean",
                            "description": "The job is waiting on an outside run (an Apify scrape); call again later."
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "status": "ok",
                  "ran": false,
                  "slices": []
                }
              }
            }
          },
          "401": {
            "description": "`CRON_SECRET` is set and the request does not carry it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "unauthorized"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "status",
          "error"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "error"
            ]
          },
          "error": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "cronSecret": {
        "type": "http",
        "scheme": "bearer",
        "description": "The deployment's `CRON_SECRET`."
      }
    }
  }
}
```
