Tree BG 1
Tree
Tree
TreeLeaves
TreeLeaves
Cat IdleGrassGrassRockRock

Beta Libraries Documents Endpoints

(beta) Libraries API - manage documents in a library.

List document in a given library.

GET /v1/libraries/{library_id}/documents

Given a library, lists the document that have been uploaded to that library.

200

Successful Response

Playground

Test the endpoints live

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

async function run() {
  const result = await mistral.beta.libraries.documents.list({
    libraryId: "5c3ca4cd-62bc-4c71-ad8a-1531ae80d078",
  });

  console.log(result);
}

run();
from mistralai import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.list(library_id="5c3ca4cd-62bc-4c71-ad8a-1531ae80d078", page_size=100, page=0, sort_by="created_at", sort_order="desc")

    # Handle response
    print(res)

curl https://api.mistral.ai/v1/libraries/{library_id}/documents \
 -X GET \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE'

200

{
  "data": [
    {
      "created_at": "2025-10-07T20:56:01.974Z",
      "extension": "ipsum eiusmod",
      "hash": "consequat do",
      "id": "reprehenderit ut dolore",
      "library_id": "occaecat dolor sit",
      "mime_type": "nostrud",
      "name": "aute aliqua aute commodo",
      "processing_status": "irure",
      "size": 87,
      "tokens_processing_total": 14,
      "uploaded_by_id": "dolor",
      "uploaded_by_type": "sunt"
    }
  ],
  "pagination": {
    "current_page": 56,
    "has_more": false,
    "page_size": 91,
    "total_items": 32,
    "total_pages": 78
  }
}

Upload a new document.

POST /v1/libraries/{library_id}/documents

Given a library, upload a new document to that library. It is queued for processing, it status will change it has been processed. The processing has to be completed in order be discoverable for the library search

200

A document with the same hash was found in this library. Returns the existing document.

created_at
*date-time
extension
*string
hash
*string
id
*string
last_processed_at
date-time|null
library_id
*string
mime_type
*string
name
*string
number_of_pages
integer|null
processing_status
*string
size
*integer
summary
string|null
tokens_processing_main_content
integer|null
tokens_processing_summary
integer|null
tokens_processing_total
*integer
uploaded_by_id
*string
uploaded_by_type
*string

Playground

Test the endpoints live

import { Mistral } from "@mistralai/mistralai";
import { openAsBlob } from "node:fs";

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

async function run() {
  const result = await mistral.beta.libraries.documents.upload({
    libraryId: "a02150d9-5ee0-4877-b62c-28b1fcdf3b76",
    requestBody: {
      file: await openAsBlob("example.file"),
    },
  });

  console.log(result);
}

run();
from mistralai import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.upload(library_id="a02150d9-5ee0-4877-b62c-28b1fcdf3b76", file={
        "file_name": "example.file",
        "content": open("example.file", "rb"),
    })

    # Handle response
    print(res)

curl https://api.mistral.ai/v1/libraries/{library_id}/documents \
 -X POST \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE' \
 -d '{
  "file": {
    "content": "ipsum eiusmod",
    "fileName": "consequat do"
  }
}'

200

{
  "created_at": "2025-10-07T20:56:01.974Z",
  "extension": "ipsum eiusmod",
  "hash": "consequat do",
  "id": "reprehenderit ut dolore",
  "library_id": "occaecat dolor sit",
  "mime_type": "nostrud",
  "name": "aute aliqua aute commodo",
  "processing_status": "irure",
  "size": 87,
  "tokens_processing_total": 14,
  "uploaded_by_id": "dolor",
  "uploaded_by_type": "sunt"
}

Retrieve the metadata of a specific document.

GET /v1/libraries/{library_id}/documents/{document_id}

Given a library and a document in this library, you can retrieve the metadata of that document.

200

Successful Response

created_at
*date-time
extension
*string
hash
*string
id
*string
last_processed_at
date-time|null
library_id
*string
mime_type
*string
name
*string
number_of_pages
integer|null
processing_status
*string
size
*integer
summary
string|null
tokens_processing_main_content
integer|null
tokens_processing_summary
integer|null
tokens_processing_total
*integer
uploaded_by_id
*string
uploaded_by_type
*string

Playground

Test the endpoints live

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

async function run() {
  const result = await mistral.beta.libraries.documents.get({
    libraryId: "03d908c8-90a1-44fd-bf3a-8490fb7c9a03",
    documentId: "90973aec-0508-4375-8b00-91d732414745",
  });

  console.log(result);
}

run();
from mistralai import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.get(library_id="03d908c8-90a1-44fd-bf3a-8490fb7c9a03", document_id="90973aec-0508-4375-8b00-91d732414745")

    # Handle response
    print(res)

curl https://api.mistral.ai/v1/libraries/{library_id}/documents/{document_id} \
 -X GET \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE'

200

{
  "created_at": "2025-10-07T20:56:01.974Z",
  "extension": "ipsum eiusmod",
  "hash": "consequat do",
  "id": "reprehenderit ut dolore",
  "library_id": "occaecat dolor sit",
  "mime_type": "nostrud",
  "name": "aute aliqua aute commodo",
  "processing_status": "irure",
  "size": 87,
  "tokens_processing_total": 14,
  "uploaded_by_id": "dolor",
  "uploaded_by_type": "sunt"
}

Update the metadata of a specific document.

PUT /v1/libraries/{library_id}/documents/{document_id}

Given a library and a document in that library, update the name of that document.

200

Successful Response

created_at
*date-time
extension
*string
hash
*string
id
*string
last_processed_at
date-time|null
library_id
*string
mime_type
*string
name
*string
number_of_pages
integer|null
processing_status
*string
size
*integer
summary
string|null
tokens_processing_main_content
integer|null
tokens_processing_summary
integer|null
tokens_processing_total
*integer
uploaded_by_id
*string
uploaded_by_type
*string

Playground

Test the endpoints live

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

async function run() {
  const result = await mistral.beta.libraries.documents.update({
    libraryId: "3ddd8d93-dca5-4a6d-980d-173226c35742",
    documentId: "2a25e44c-b160-40ca-b5c2-b65fb2fcae34",
    documentUpdateIn: {},
  });

  console.log(result);
}

run();
from mistralai import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.update(library_id="3ddd8d93-dca5-4a6d-980d-173226c35742", document_id="2a25e44c-b160-40ca-b5c2-b65fb2fcae34")

    # Handle response
    print(res)

curl https://api.mistral.ai/v1/libraries/{library_id}/documents/{document_id} \
 -X PUT \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE' \
 -d '{}'

200

{
  "created_at": "2025-10-07T20:56:01.974Z",
  "extension": "ipsum eiusmod",
  "hash": "consequat do",
  "id": "reprehenderit ut dolore",
  "library_id": "occaecat dolor sit",
  "mime_type": "nostrud",
  "name": "aute aliqua aute commodo",
  "processing_status": "irure",
  "size": 87,
  "tokens_processing_total": 14,
  "uploaded_by_id": "dolor",
  "uploaded_by_type": "sunt"
}

Delete a document.

DELETE /v1/libraries/{library_id}/documents/{document_id}

Given a library and a document in that library, delete that document. The document will be deleted from the library and the search index.

Playground

Test the endpoints live

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

async function run() {
  await mistral.beta.libraries.documents.delete({
    libraryId: "005daae9-d42e-407d-82d7-2261c6a1496c",
    documentId: "edc236b0-baff-49a9-884b-4ca36a258da4",
  });


}

run();
from mistralai import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    mistral.beta.libraries.documents.delete(library_id="005daae9-d42e-407d-82d7-2261c6a1496c", document_id="edc236b0-baff-49a9-884b-4ca36a258da4")

    # Use the SDK ...

curl https://api.mistral.ai/v1/libraries/{library_id}/documents/{document_id} \
 -X DELETE \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE'

Retrieve the text content of a specific document.

GET /v1/libraries/{library_id}/documents/{document_id}/text_content

Given a library and a document in that library, you can retrieve the text content of that document if it exists. For documents like pdf, docx and pptx the text content results from our processing using Mistral OCR.

200

Successful Response

text
*string

Playground

Test the endpoints live

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

async function run() {
  const result = await mistral.beta.libraries.documents.textContent({
    libraryId: "1d177215-3b6b-45ba-9fa9-baf773223bec",
    documentId: "60214c91-2aba-4692-a4e6-a53365de8caf",
  });

  console.log(result);
}

run();
from mistralai import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.text_content(library_id="1d177215-3b6b-45ba-9fa9-baf773223bec", document_id="60214c91-2aba-4692-a4e6-a53365de8caf")

    # Handle response
    print(res)

curl https://api.mistral.ai/v1/libraries/{library_id}/documents/{document_id}/text_content \
 -X GET \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE'

200

{
  "text": "ipsum eiusmod"
}

Retrieve the processing status of a specific document.

GET /v1/libraries/{library_id}/documents/{document_id}/status

Given a library and a document in that library, retrieve the processing status of that document.

200

Successful Response

document_id
*string
processing_status
*string

Playground

Test the endpoints live

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

async function run() {
  const result = await mistral.beta.libraries.documents.status({
    libraryId: "e6906f70-368f-4155-80da-c1718f01bc43",
    documentId: "2c904915-d831-4e9d-a345-8ce405bcef66",
  });

  console.log(result);
}

run();
from mistralai import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.status(library_id="e6906f70-368f-4155-80da-c1718f01bc43", document_id="2c904915-d831-4e9d-a345-8ce405bcef66")

    # Handle response
    print(res)

curl https://api.mistral.ai/v1/libraries/{library_id}/documents/{document_id}/status \
 -X GET \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE'

200

{
  "document_id": "ipsum eiusmod",
  "processing_status": "consequat do"
}

Retrieve the signed URL of a specific document.

GET /v1/libraries/{library_id}/documents/{document_id}/signed-url

Given a library and a document in that library, retrieve the signed URL of a specific document.The url will expire after 30 minutes and can be accessed by anyone with the link.

200

Response Type
string

Successful Response

Playground

Test the endpoints live

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

async function run() {
  const result = await mistral.beta.libraries.documents.getSignedUrl({
    libraryId: "23cf6904-a602-4ee8-9f5b-8efc557c336d",
    documentId: "48598486-df71-4994-acbb-1133c72efa8c",
  });

  console.log(result);
}

run();
from mistralai import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.get_signed_url(library_id="23cf6904-a602-4ee8-9f5b-8efc557c336d", document_id="48598486-df71-4994-acbb-1133c72efa8c")

    # Handle response
    print(res)

curl https://api.mistral.ai/v1/libraries/{library_id}/documents/{document_id}/signed-url \
 -X GET \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE'

200

"ipsum eiusmod"

Retrieve the signed URL of text extracted from a given document.

GET /v1/libraries/{library_id}/documents/{document_id}/extracted-text-signed-url

Given a library and a document in that library, retrieve the signed URL of text extracted. For documents that are sent to the OCR this returns the result of the OCR queries.

200

Response Type
string

Successful Response

Playground

Test the endpoints live

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

async function run() {
  const result = await mistral.beta.libraries.documents.extractedTextSignedUrl({
    libraryId: "a6f15de3-1e82-4f95-af82-851499042ef8",
    documentId: "9749d4f9-24e5-4ca2-99a3-a406863f805d",
  });

  console.log(result);
}

run();
from mistralai import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.extracted_text_signed_url(library_id="a6f15de3-1e82-4f95-af82-851499042ef8", document_id="9749d4f9-24e5-4ca2-99a3-a406863f805d")

    # Handle response
    print(res)

curl https://api.mistral.ai/v1/libraries/{library_id}/documents/{document_id}/extracted-text-signed-url \
 -X GET \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE'

200

"ipsum eiusmod"

Reprocess a document.

POST /v1/libraries/{library_id}/documents/{document_id}/reprocess

Given a library and a document in that library, reprocess that document, it will be billed again.

Playground

Test the endpoints live

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

async function run() {
  await mistral.beta.libraries.documents.reprocess({
    libraryId: "51b29371-de8f-4ba4-932b-a0bafb3a7f64",
    documentId: "3052422c-49ca-45ac-a918-cadb35d61fd8",
  });


}

run();
from mistralai import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    mistral.beta.libraries.documents.reprocess(library_id="51b29371-de8f-4ba4-932b-a0bafb3a7f64", document_id="3052422c-49ca-45ac-a918-cadb35d61fd8")

    # Use the SDK ...

curl https://api.mistral.ai/v1/libraries/{library_id}/documents/{document_id}/reprocess \
 -X POST \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE'