> For the complete documentation index, see [llms.txt](https://docs.fylr.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fylr.io/for-developers/api/endpoints/api-oai.md).

# /api/v1/oai

[OAI-PMH](https://www.openarchives.org/OAI/openarchivesprotocol.html) endpoint. Implements the Open Archives Initiative Protocol for Metadata Harvesting (version 2.0) so external harvesters can pull metadata from fylr. The protocol uses a single URL with a `verb` query parameter and returns XML.

Must be enabled in the base config (`fylr.oai_pmh.enabled = true`), otherwise every request returns HTTP 400 with `code: OAIpmhNotEnabled`. Protocol-level errors are returned inside the XML response body as an `<error code="…">` element AND carry the matching HTTP status: `badArgument` / `badVerb` / `cannotDisseminateFormat` / `badResumptionToken` → 400, `idDoesNotExist` → 404, internal failures → 500. Only a successful harvest is `200 OK`.

The endpoint requires no rights and accepts anonymous requests: when no user can be derived from the session, the built-in `system:oai_pmh` user is used. There is no read-only-mode guard. A `ListRecords` or `GetRecord` harvest logs an `OBJECT_DOWNLOAD` event per record (written in a background transaction), but the request itself runs in a read transaction — nothing else is persisted.

### `GET /oai` — OAI-PMH protocol entry point.

{% openapi src="/files/kfiDjhyZfEICNBmt5f49" path="/oai" method="get" %}
[fylr-openapi.yml](https://4100607288-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAdRFzQASDY2Elfdm3wXW%2Fuploads%2Fgit-blob-d5aceac1c99d5aa0b623bea061400efbac147a8d%2Ffylr-openapi.yml?alt=media)
{% endopenapi %}

### `HEAD /oai` — HEAD on the OAI-PMH endpoint.

{% openapi src="/files/kfiDjhyZfEICNBmt5f49" path="/oai" method="head" %}
[fylr-openapi.yml](https://4100607288-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAdRFzQASDY2Elfdm3wXW%2Fuploads%2Fgit-blob-d5aceac1c99d5aa0b623bea061400efbac147a8d%2Ffylr-openapi.yml?alt=media)
{% endopenapi %}


---

# 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 dynamically by asking a question.

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

```
GET https://docs.fylr.io/for-developers/api/endpoints/api-oai.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.
