### Install Dependencies and Start Development Server Source: https://github.com/papra-hq/papra/blob/main/apps/papra-client/README.md Use these commands to navigate to the client directory, install project dependencies, and start the local development server. Ensure the server is running locally unless in demo mode. ```bash cd apps/papra-client pnpm install pnpm dev ``` -------------------------------- ### Start Papra Development Server Source: https://github.com/papra-hq/papra/blob/main/apps/papra-server/README.md Navigate to the server directory, install dependencies, and start the development server. The server will be accessible at http://localhost:1221. ```bash cd apps/papra-server pnpm install pnpm dev ``` -------------------------------- ### Start Papra Docs Development Server Source: https://github.com/papra-hq/papra/blob/main/apps/docs/README.md Run these commands to navigate to the docs directory, install dependencies, and start the development server. The server will be available at http://localhost:4321. ```bash # Navigate to the docs directory cd apps/docs # Install dependencies pnpm install # Start the development server pnpm dev ``` -------------------------------- ### Start Frontend Development Server Source: https://github.com/papra-hq/papra/blob/main/CONTRIBUTING.md Navigate to the client directory and start the development server for the frontend. ```bash cd apps/papra-client pnpm dev ``` -------------------------------- ### Install @papra/lecture with pnpm, npm, or yarn Source: https://github.com/papra-hq/papra/blob/main/packages/lecture/README.md Install the package using your preferred package manager. ```bash pnpm install @papra/lecture ``` ```bash npm install @papra/lecture ``` ```bash yarn add @papra/lecture ``` -------------------------------- ### Start Documentation Server Source: https://github.com/papra-hq/papra/blob/main/CONTRIBUTING.md Navigate to the docs directory and start the documentation server for local development using pnpm dev. ```bash cd apps/docs pnpm dev ``` -------------------------------- ### Start Development Server Source: https://github.com/papra-hq/papra/blob/main/apps/website/README.md Run this command to start the local development server. This allows you to preview changes in real-time. ```bash pnpm dev ``` -------------------------------- ### Install @papra/search-parser Source: https://github.com/papra-hq/papra/blob/main/packages/search-parser/README.md Install the library using your preferred package manager. ```bash pnpm add @papra/search-parser # or npm install @papra/search-parser # or yarn add @papra/search-parser ``` -------------------------------- ### Install Dependencies Source: https://github.com/papra-hq/papra/blob/main/CONTRIBUTING.md Install project dependencies using pnpm. ```bash pnpm install ``` -------------------------------- ### Run Backend Migrations and Start Server Source: https://github.com/papra-hq/papra/blob/main/CONTRIBUTING.md Navigate to the server directory, run the migration script to create the database schema, and then start the development server. ```bash cd apps/papra-server pnpm migrate:up pnpm dev ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/04-from-source.mdx Install all necessary dependencies for the Papra project using pnpm. ```bash pnpm install ``` -------------------------------- ### Install Cadence-MQ Core and LibSQL Driver Source: https://github.com/papra-hq/papra/blob/main/apps/website/src/content/blog/introducing-cadence-mq.mdx Install the necessary packages for Cadence-MQ core functionality and the LibSQL driver using pnpm. ```bash pnpm install @cadence-mq/core @cadence-mq/driver-libsql ``` -------------------------------- ### Install Papra CLI Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/04-resources/02-cli.mdx Install the Papra CLI globally using your preferred package manager. ```bash # using pnpm pnpm i -g @papra/cli # or using npm npm i -g @papra/cli # or using yarn yarn add -g @papra/cli ``` -------------------------------- ### YAML Configuration Example Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/03-configuration.mdx Example of a Papra configuration file in YAML format. This file can be placed in the project root or a specified directory. ```yaml server: baseUrl: https://papra.example.com corsOrigins: * client: baseUrl: https://papra.example.com auth: secret: your-secret-key isRegistrationEnabled: true # ... ``` -------------------------------- ### Start Papra Server with Migrations Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/04-from-source.mdx Run the Papra server, ensuring database migrations are applied. ```bash pnpm start:with-migrations ``` -------------------------------- ### JSON Configuration Example with Schema Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/03-configuration.mdx Example of a Papra configuration file in JSON format. Includes a $schema property for IDE autocompletion using the provided schema file. ```json { "$schema": "https://docs.papra.app/papra-config-schema.json", "server": { "baseUrl": "https://papra.example.com" }, "client": { "baseUrl": "https://papra.example.com" }, "auth": { "secret": "your-secret-key", "isRegistrationEnabled": true } } ``` -------------------------------- ### OIDC Provider Configuration Example Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/04-setup-custom-oauth2.mdx Example JSON configuration for an OIDC provider. Use 'discoveryUrl' for automatic endpoint configuration. ```json [ { "providerId": "custom-oauth2", "providerName": "Custom OAuth2", "providerIconUrl": "https://api.iconify.design/tabler:login-2.svg", "clientId": "your-client-id", "clientSecret": "your-client-secret", "type": "oidc", "discoveryUrl": "https://your-provider.tld/.well-known/openid-configuration", "scopes": ["openid", "profile", "email"] } ] ``` -------------------------------- ### Filesystem to S3 Migration Example Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/10-migrate-document-storage.mdx Moves documents from a local filesystem to an S3 bucket. AWS credentials should be configured in the environment. ```bash docker compose exec papra pnpm maintenance:migrate-document-storage \ --from DOCUMENT_STORAGE_DRIVER=filesystem \ --from DOCUMENT_STORAGE_FILESYSTEM_ROOT=./app-data/documents \ --to DOCUMENT_STORAGE_DRIVER=s3 \ --to DOCUMENT_STORAGE_S3_BUCKET_NAME=my-papra-bucket \ --to DOCUMENT_STORAGE_S3_REGION=us-east-1 ``` -------------------------------- ### Actual Migration with Source Installation Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/10-migrate-document-storage.mdx Performs the actual document storage migration for a source installation. This command copies documents to the new storage backend. ```bash pnpm maintenance:migrate-document-storage \ --from DOCUMENT_STORAGE_DRIVER=filesystem \ --to DOCUMENT_STORAGE_DRIVER=s3 \ --to DOCUMENT_STORAGE_S3_BUCKET_NAME=my-bucket \ --to DOCUMENT_STORAGE_S3_REGION=us-east-1 ``` -------------------------------- ### Verify Docker Installation Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/01-using-docker.mdx Check if Docker is installed on your system. ```bash docker --version ``` -------------------------------- ### Install Papra Webhooks Package Source: https://github.com/papra-hq/papra/blob/main/apps/website/src/content/blog/papra-04.mdx Install the Papra webhooks package to easily consume and verify webhook events from your Papra instance. ```bash pnpm install @papra/webhooks # or npm install @papra/webhooks # or yarn add @papra/webhooks ``` -------------------------------- ### Initialize Papra CLI Configuration Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/04-resources/02-cli.mdx Run this command to start the configuration process for the Papra CLI. It will prompt for your instance URL and API key. ```bash papra config init ``` -------------------------------- ### Verify Docker Installation Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/02-using-docker-compose.mdx Check if Docker and Docker Compose are installed on your system. ```bash docker --version docker compose version ``` -------------------------------- ### Install Papra TypeScript/JavaScript SDK Source: https://github.com/papra-hq/papra/blob/main/apps/website/src/content/blog/papra-04.mdx Install the Papra SDK using your preferred package manager. This SDK provides type-safe interaction with the Papra API. ```bash pnpm install @papra/api-sdk # or npm install @papra/api-sdk # or yarn add @papra/api-sdk ``` -------------------------------- ### Log Hello World to Console Source: https://github.com/papra-hq/papra/blob/main/packages/lecture/fixtures/004-markdown/004.expected.txt A basic JavaScript snippet to print 'Hello, World!' to the console. No specific setup is required. ```javascript console.log('Hello, World!'); ``` -------------------------------- ### Install @papra/webhooks with npm Source: https://github.com/papra-hq/papra/blob/main/packages/webhooks/README.md Use this command to add the @papra/webhooks package to your project using npm. ```bash npm install @papra/webhooks ``` -------------------------------- ### Install Papra CLI Source: https://github.com/papra-hq/papra/blob/main/apps/website/src/content/blog/papra-04.mdx Install the Papra Command Line Interface globally using npm, pnpm, or yarn. This CLI simplifies managing your Papra instance from the terminal. ```bash # Install the CLI pnpm install -g @papra/cli # or npm install -g @papra/cli # or yarn add -g @papra/cli ``` -------------------------------- ### Date Filter Examples Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/08-advanced-search.mdx Demonstrates various date comparison operators and formats for 'created:' and 'date:' filters. ```yaml # Finds documents created exactly on January 15th, 2024 at 00:00:00 created:2024-01-15 # Finds documents created after January 1st, 2024 created:>2024 # Finds documents created on or after January 1st, 2024 created:>=2024-01-01 # Finds documents created before December 31st, 2024 created:<2024-12-31 # Finds documents created on or before June 30th, 2024 created:<=2024-06-30 # Finds invoices created only in 2024 tag:invoice created:>2024 created:<2025 # Finds documents with a document date after January 1st, 2024 date:>2024 # Finds documents with a document date on or before now date:<=now ``` -------------------------------- ### Standard OAuth2 Provider Configuration Example Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/04-setup-custom-oauth2.mdx Example JSON configuration for a standard OAuth2 provider. Manually specify authorization, token, and user info endpoints. ```json [ { "providerId": "custom-oauth2", "providerName": "Custom OAuth2", "providerIconUrl": "https://api.iconify.design/tabler:login-2.svg", "clientId": "your-client-id", "clientSecret": "your-client-secret", "type": "oauth2", "authorizationUrl": "https://your-provider.tld/oauth2/authorize", "tokenUrl": "https://your-provider.tld/oauth2/token", "userInfoUrl": "https://your-provider.tld/oauth2/userinfo", "scopes": ["profile", "email"] } ] ``` -------------------------------- ### Create Papra Server Configuration (YAML) Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/04-from-source.mdx Example of a Papra server configuration file in YAML format, including server and authentication settings. ```yaml server: servePublicDir: true baseUrl: http://localhost:1221 auth: secret: ``` -------------------------------- ### Install @papra/webhooks with pnpm Source: https://github.com/papra-hq/papra/blob/main/packages/webhooks/README.md Use this command to add the @papra/webhooks package to your project using pnpm. ```bash pnpm add @papra/webhooks ``` -------------------------------- ### Create Papra Server Configuration (JSON) Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/04-from-source.mdx Example of a Papra server configuration file in JSON format, including schema, server, and authentication settings. ```json { "$schema": "https://docs.papra.app/papra-config-schema.json", "server": { "servePublicDir": true, "baseUrl": "http://localhost:1221" }, "auth": { "secret": "" } } ``` -------------------------------- ### S3 to S3-Compatible Storage Migration Example Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/10-migrate-document-storage.mdx Migrates documents from one S3 bucket to another, potentially using an S3-compatible service like Cloudflare R2 or MinIO. Requires specifying the S3 endpoint. ```bash docker compose exec papra pnpm maintenance:migrate-document-storage \ --from DOCUMENT_STORAGE_DRIVER=s3 \ --from DOCUMENT_STORAGE_S3_BUCKET_NAME=old-bucket \ --from DOCUMENT_STORAGE_S3_REGION=us-east-1 \ --to DOCUMENT_STORAGE_DRIVER=s3 \ --to DOCUMENT_STORAGE_S3_BUCKET_NAME=new-bucket \ --to DOCUMENT_STORAGE_S3_ENDPOINT=https://.r2.cloudflarestorage.com \ --to DOCUMENT_STORAGE_S3_REGION=auto ``` -------------------------------- ### Install @papra/webhooks with yarn Source: https://github.com/papra-hq/papra/blob/main/packages/webhooks/README.md Use this command to add the @papra/webhooks package to your project using yarn. ```bash yarn add @papra/webhooks ``` -------------------------------- ### Get Papra CLI Help Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/04-resources/02-cli.mdx Access help information for the Papra CLI and its subcommands using the `--help` flag. ```bash papra --help papra config --help papra documents --help ``` -------------------------------- ### Docker Compose Configuration for Storage Key Patterns Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/09-storage-key-patterns.mdx Example Docker Compose configuration to enable and set the storage key pattern. Ensure these environment variables are correctly set for the Papra service. ```yaml services: papra: container_name: papra image: ghcr.io/papra-hq/papra:latest restart: unless-stopped environment: # ... other environment variables ... - DOCUMENT_STORAGE_USE_LEGACY_STORAGE_KEY_DEFINITION_SYSTEM=false - DOCUMENT_STORAGE_KEY_PATTERN={{organization.id}}/{{document.name}} volumes: - ./app-data:/app/app-data ports: - "1221:1221" ``` -------------------------------- ### Verify Node.js and pnpm Versions Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/04-from-source.mdx Check if Node.js and pnpm are installed and meet the minimum version requirements. ```bash node --version ``` ```bash pnpm --version ``` -------------------------------- ### S3 to Azure Blob Storage Migration Example Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/10-migrate-document-storage.mdx Migrates documents from an S3 bucket to an Azure Blob Storage container. Requires S3 and Azure credentials to be configured. ```bash docker compose exec papra pnpm maintenance:migrate-document-storage \ --from DOCUMENT_STORAGE_DRIVER=s3 \ --from DOCUMENT_STORAGE_S3_BUCKET_NAME=old-bucket \ --from DOCUMENT_STORAGE_S3_REGION=us-east-1 \ --to DOCUMENT_STORAGE_DRIVER=azure-blob \ --to DOCUMENT_STORAGE_AZURE_BLOB_ACCOUNT_NAME=myaccount \ --to DOCUMENT_STORAGE_AZURE_BLOB_CONTAINER_NAME=papra-documents ``` -------------------------------- ### List Organizations using cURL Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/04-resources/03-api-endpoints.mdx Example of how to list all organizations accessible to the authenticated user using cURL. Ensure you replace YOUR_API_TOKEN with your actual token. ```bash curl -H "Authorization: Bearer YOUR_API_TOKEN" \ https://api.papra.app/api/organizations ``` -------------------------------- ### Legacy Storage Key Format Example Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/09-storage-key-patterns.mdx The legacy system generates keys using the organization ID, a fixed 'originals' directory, and the document ID. Conflicts are impossible with this format. ```text {{organization.id}}/originals/{{document.id}} ``` ```text org_abc123/originals/doc_123456789012345678901234 ``` -------------------------------- ### Start Papra Service with Docker Compose Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/02-using-docker-compose.mdx Launch the Papra container in detached mode, setting user and group IDs for proper file permissions. ```bash UID=$(id -u) GID=$(id -g) docker compose up -d ``` -------------------------------- ### Run Dry-Run for Document Encryption Migration (Source Installation) Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/05-setup-document-encryption.mdx Execute a dry-run of the document encryption migration from your Papra server directory to preview which documents will be affected without performing any actual encryption. ```bash # From your Papra server directory pnpm maintenance:encrypt-all-documents --dry-run ``` -------------------------------- ### Example Storage Key Pattern with Date Expressions Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/09-storage-key-patterns.mdx Demonstrates a storage key pattern that includes the organization ID, year, month, day, and document name, utilizing various date expressions for organization. ```plaintext {{organization.id}}/{{currentDate.yyyy}}/{{currentDate.MM}}/{{document.name}} ``` -------------------------------- ### Run Papra Docker Container Source: https://github.com/papra-hq/papra/blob/main/README.md Quickly start a Papra instance using Docker. Ensure to replace the dummy AUTH_SECRET with a securely generated one for production environments. ```bash docker run -d --name papra -p 1221:1221 -e AUTH_SECRET=a-dummy-secret-for-testing-purposes-only ghcr.io/papra-hq/papra:latest ``` -------------------------------- ### List Organizations using JavaScript Fetch Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/04-resources/03-api-endpoints.mdx Example of how to list all organizations accessible to the authenticated user using the JavaScript fetch API. Remember to include the Authorization header. ```javascript const response = await fetch('https://api.papra.app/api/organizations', { headers: { 'Authorization': 'Bearer YOUR_API_TOKEN', 'Content-Type': 'application/json' } }) ``` -------------------------------- ### Initialize Papra API Client Source: https://github.com/papra-hq/papra/blob/main/apps/website/src/content/blog/papra-04.mdx Create a Papra API client instance using your API key and optionally specify the API base URL. Store your API key securely, for example, in an environment variable. ```typescript import { createClient } from '@papra/api-sdk'; const client = createClient({ // The API key can be found in your user settings (under /api-keys) // you may want to store this in an environment variable apiKey: 'ppapi_...', // Optional: base URL of the API apiBaseUrl: 'http://papra.your-instance.tld', }); const myFile = new File(['test'], 'test.txt', { type: 'text/plain' }); await client.uploadDocument({ file: myFile, organizationId: 'org_...', // The id of the organization you want to upload the document to }); ``` -------------------------------- ### Pad Start Transformer Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/09-storage-key-patterns.mdx Pads the start of a value to a target length, with an optional pad character. Defaults to a space. ```text {{currentDate.MM | padStart 2 0}} ``` -------------------------------- ### Create API Key and Authenticate Source: https://context7.com/papra-hq/papra/llms.txt Use this to create a new API key for integration and then use the obtained token for subsequent authenticated requests. ```bash # Create an API key (requires an authenticated session cookie) curl -X POST https://api.papra.app/api/api-keys \ -H "Content-Type: application/json" \ -d '{ "name": "My Integration Key", "permissions": [ "organizations:read", "documents:create", "documents:read", "tags:read", "tags:create" ] }' # Response: { "apiKey": { "id": "...", "name": "..." }, "token": "ppapi_..." } # Use the token in subsequent requests curl https://api.papra.app/api/organizations \ -H "Authorization: Bearer ppapi_..." ``` -------------------------------- ### Copy Client Files to Server Public Directory Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/04-from-source.mdx Create the public directory for the server and copy the built client files into it. ```bash mkdir -p apps/papra-server/public cp -r apps/papra-client/dist/* apps/papra-server/public/ ``` -------------------------------- ### Create Papra Data Directories Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/01-using-docker.mdx Prepare the necessary directories for persistent data storage for Papra. ```bash mkdir -p ./papra-data/{db,documents} ``` -------------------------------- ### Create Organization Ingestion Directory and File Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/03-setup-ingestion-folder.mdx Create the necessary directory structure for an organization's ingestion folder and add a sample file. ```bash mkdir -p / touch //hello.txt ``` -------------------------------- ### Initialize Project Structure for Docker Compose Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/02-using-docker-compose.mdx Create the necessary directory structure for Papra's data persistence when using Docker Compose. ```bash mkdir -p papra/app-data/{db,documents} && cd papra ``` -------------------------------- ### Initialize Client Source: https://github.com/papra-hq/papra/blob/main/packages/api-sdk/README.md Instantiate the Papra API client with your API key and optional base URL. ```APIDOC ## Initialize Client ### Description Instantiate the Papra API client with your API key and optional base URL. ### Method `createClient(options: { apiKey: string; apiBaseUrl?: string })` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript import { createClient } from '@papra/api-sdk'; const client = createClient({ apiKey: 'ppapi_...', // Your API key apiBaseUrl: 'http://papra.your-instance.tld', // Optional: base URL of the API }); ``` ### Response #### Success Response (200) Returns an initialized client object. #### Response Example ```json { "client": "initialized client object" } ``` ``` -------------------------------- ### Dry Run Migration with Source Installation Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/10-migrate-document-storage.mdx Executes a dry run of the document storage migration for a source installation. This command logs all documents that would be migrated without altering any files. ```bash pnpm maintenance:migrate-document-storage \ --from DOCUMENT_STORAGE_DRIVER=filesystem \ --to DOCUMENT_STORAGE_DRIVER=s3 \ --to DOCUMENT_STORAGE_S3_BUCKET_NAME=my-bucket \ --to DOCUMENT_STORAGE_S3_REGION=us-east-1 \ --dry-run ``` -------------------------------- ### Build and Deploy Email Worker with Wrangler Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/02-intake-emails-with-cf-email-worker.mdx Clone the email-proxy repository, install dependencies, build the worker, and deploy it using the Wrangler CLI. Ensure Node.js v24 and pnpm are installed. ```bash git clone https://github.com/papra-hq/email-proxy.git cd email-proxy pnpm install pnpm build pnpm deploy ``` -------------------------------- ### Get document activity Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/04-resources/03-api-endpoints.mdx Retrieves the activity log for a specific document. ```APIDOC ## GET /api/organizations/:organizationId/documents/:documentId/activity ### Description Get the activity log of a document. ### Method GET ### Endpoint `/api/organizations/:organizationId/documents/:documentId/activity` ### Parameters #### Path Parameters - **organizationId** (string) - Required - The ID of the organization. - **documentId** (string) - Required - The ID of the document. #### Query Parameters - **pageIndex** (integer) - Optional - The page index to start from. Defaults to 0. - **pageSize** (integer) - Optional - The number of documents to return. Defaults to 100. ### Response #### Success Response (200) - **activities** (array) - The list of activities. ``` -------------------------------- ### Storage Migration CLI Reference Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/10-migrate-document-storage.mdx This command-line interface reference outlines the options available for the document storage migration script. Use `--from` and `--to` to specify source and destination storage configurations, `--delete-source` to remove original files, and `--dry-run` to preview changes. ```bash maintenance:migrate-document-storage [options] Options: --from Source storage environment variable (repeatable) --to Destination storage environment variable (repeatable) --delete-source Delete source files after a successful copy --dry-run Preview what would be migrated without touching any files -h, --help Show this help message ``` -------------------------------- ### Get a document file Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/04-resources/03-api-endpoints.mdx Retrieves the content of a specific document file by its ID. ```APIDOC ## GET /api/organizations/:organizationId/documents/:documentId/file ### Description Get a document file content by its ID. ### Method GET ### Endpoint `/api/organizations/:organizationId/documents/:documentId/file` ### Parameters #### Path Parameters - **organizationId** (string) - Required - The ID of the organization. - **documentId** (string) - Required - The ID of the document. ### Response #### Success Response (200) - The document file stream. ``` -------------------------------- ### Get an organization Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/04-resources/03-api-endpoints.mdx Retrieves a specific organization by its ID. Requires the `organizations:read` permission. ```APIDOC ## GET /api/organizations/:organizationId ### Description Get an organization by its ID. ### Method GET ### Endpoint /api/organizations/:organizationId ### Parameters #### Path Parameters - `organizationId` (string) - Required - The ID of the organization to retrieve. ### Request Example None ### Response #### Success Response (200) - `organization` (object) - The organization. #### Response Example ```json { "organization": { "id": "org_abcde", "name": "Example Organization" } } ``` ``` -------------------------------- ### Clone Papra Repository and Navigate Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/04-from-source.mdx Clone the Papra repository from GitHub and change the current directory to the project root. ```bash git clone https://github.com/papra-hq/papra.git cd papra ``` -------------------------------- ### Basic Cadence-MQ Usage with LibSQL Source: https://github.com/papra-hq/papra/blob/main/apps/website/src/content/blog/introducing-cadence-mq.mdx Set up and use Cadence-MQ with a LibSQL backend to register a task and schedule a job. Ensure the LibSQL client is properly configured. ```typescript import { createQueue } from '@cadence-mq/core'; import { createLibSqlDriver } from '@cadence-mq/driver-libsql'; import { createClient } from '@libsql/client'; const client = createClient({ url: 'file:./cadence-mq.db' }); const queue = createQueue({ driver: createLibSqlDriver({ client }) }); queue.registerTask({ name: 'send-welcome-email', handler: async ({ data }) => { console.log(`Sending welcome email to ${data.email}`); }, }); queue.startWorker({ workerId: 'worker-1' }); await queue.scheduleJob({ taskName: 'send-welcome-email', data: { email: 'test@test.com' }, }); ``` -------------------------------- ### Pull Latest Papra Changes Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/04-from-source.mdx Update your local Papra installation by pulling the latest changes from the main branch. ```bash git pull origin main ``` -------------------------------- ### Enable Legacy Storage Key System Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/09-storage-key-patterns.mdx To continue using the legacy storage key system, set this environment variable to true. This is the default behavior. ```bash DOCUMENT_STORAGE_USE_LEGACY_STORAGE_KEY_DEFINITION_SYSTEM=true ``` -------------------------------- ### Transformer Chaining Example Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/09-storage-key-patterns.mdx Multiple transformers can be chained together using the pipe operator to apply transformations sequentially. ```text {{document.name | lowercase | padEnd 20 _}} ``` -------------------------------- ### Configure Papra Instance for Intake Emails Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/02-intake-emails-with-cf-email-worker.mdx Set environment variables in your Papra instance to enable intake emails, configure the driver to catch-all, specify the catch-all domain, and set a webhook secret for authentication. ```bash INTAKE_EMAILS_IS_ENABLED=true INTAKE_EMAILS_DRIVER=catch-all INTAKE_EMAILS_CATCH_ALL_DOMAIN=papra.email INTAKE_EMAILS_WEBHOOK_SECRET=a-random-key ``` -------------------------------- ### Get organization documents statistics Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/04-resources/03-api-endpoints.mdx Retrieves statistics, including the count and total size, of documents within an organization. ```APIDOC ## GET /api/organizations/:organizationId/documents/statistics ### Description Get the statistics (number of documents and total size) of the documents in the organization. ### Method GET ### Endpoint `/api/organizations/:organizationId/documents/statistics` ### Parameters #### Path Parameters - **organizationId** (string) - Required - The ID of the organization. ### Response #### Success Response (200) - **organizationStats** (object) - The organization documents statistics. - **documentsCount** (integer) - The total number of documents. - **documentsSize** (integer) - The total size of the documents. ``` -------------------------------- ### Get a document Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/04-resources/03-api-endpoints.mdx Retrieves a specific document by its ID within a specified organization. Requires the `documents:read` permission. ```APIDOC ## GET /api/organizations/:organizationId/documents/:documentId ### Description Get a document by its ID. ### Method GET ### Endpoint /api/organizations/:organizationId/documents/:documentId ### Parameters #### Path Parameters - `organizationId` (string) - Required - The ID of the organization the document belongs to. - `documentId` (string) - Required - The ID of the document to retrieve. ### Request Example None ### Response #### Success Response (200) - `document` (object) - The document. #### Response Example ```json { "document": { "id": "doc_xyz789", "organizationId": "org_abcde", "name": "example.pdf", "status": "processed", "createdAt": "2023-10-26T12:00:00Z" } } ``` ``` -------------------------------- ### Update Papra Docker Image Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/01-using-docker.mdx Pull the latest Papra image from either GHCR or Docker Hub to update your installation. ```bash docker pull ghcr.io/papra-hq/papra:latest # Or docker pull corentinth/papra:latest ``` -------------------------------- ### papra config Source: https://context7.com/papra-hq/papra/llms.txt Sets up the CLI with an API key, instance URL, and optional default organization ID. Configuration is persisted to the OS app-data directory. ```APIDOC ### `papra config` — Configure the CLI Sets up the CLI with an API key, instance URL, and optional default organization ID. Configuration is persisted to the OS app-data directory. ```bash # Interactive wizard (prompts for all values) papra config init # List current configuration papra config list # Output: { "apiUrl": "https://api.papra.app", "apiKey": "ppapi_...", "defaultOrganizationId": "org_abc123" } # Set individual values non-interactively papra config set api-key ppapi_my_secret_key papra config set api-url https://papra.selfhosted.example.com papra config set default-org-id org_abc123 ``` ``` -------------------------------- ### Enable Storage Key Patterns Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/09-storage-key-patterns.mdx Set this environment variable to disable the legacy system and enable the new pattern-based storage key system. This affects newly uploaded documents. ```bash DOCUMENT_STORAGE_USE_LEGACY_STORAGE_KEY_DEFINITION_SYSTEM=false ``` -------------------------------- ### Quick Papra Deployment with Docker Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/01-using-docker.mdx Launch Papra using the latest rootless Docker image with default configurations. This command exposes the web interface and sets up automatic restarts. ```bash docker run -d \ --name papra \ --restart unless-stopped \ --env APP_BASE_URL=http://localhost:1221 \ --env AUTH_SECRET= \ -p 1221:1221 \ ghcr.io/papra-hq/papra:latest ``` -------------------------------- ### Get Public Server Configuration Source: https://context7.com/papra-hq/papra/llms.txt Fetches the publicly accessible server configuration, including details about authentication providers and feature flags. ```APIDOC ## GET /api/config ### Description Retrieves the public server configuration, which may include details on available authentication methods and feature enablement. ### Method GET ### Endpoint /api/config ### Response #### Success Response (200) - **config** (object) - The server configuration object. - **auth** (object) - Authentication-related configuration. - **isRegistrationEnabled** (boolean) - Indicates if user registration is currently enabled. - **providers** (array of strings) - A list of available authentication providers (e.g., "github", "google"). ### Response Example ```json { "config": { "auth": { "isRegistrationEnabled": true, "providers": ["github", "google"] } } } ``` ``` -------------------------------- ### Inspect Current API Key Source: https://context7.com/papra-hq/papra/llms.txt Get details about the API key used for the current request, including its identity and granted permissions. ```bash curl https://api.papra.app/api/api-keys/current \ -H "Authorization: Bearer ppapi_..." # Response: # { # "apiKey": { # "id": "key_abc123", # "name": "My Integration Key", # "permissions": ["documents:create", "documents:read", "tags:read"] # } # } ``` -------------------------------- ### Build All Papra Packages Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/02-self-hosting/04-from-source.mdx Build all packages within the Papra monorepo. ```bash pnpm -r build ``` -------------------------------- ### Clone Papra Repository Source: https://github.com/papra-hq/papra/blob/main/CONTRIBUTING.md Clone the Papra repository and navigate into the project directory to begin local development. ```bash git clone https://github.com/papra-hq/papra.git cd papra ``` -------------------------------- ### Configure Custom OAuth2 Providers Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/04-setup-custom-oauth2.mdx Set the AUTH_PROVIDERS_CUSTOMS environment variable with an array of provider configurations. This example shows a configuration for an OIDC provider. ```bash AUTH_PROVIDERS_CUSTOMS='[ { "providerId": "custom-oauth2", "providerName": "Custom OAuth2", "providerIconUrl": "https://api.iconify.design/tabler:login-2.svg", "clientId": "your-client-id", "clientSecret": "your-client-secret", "type": "oidc", "discoveryUrl": "https://your-provider.tld/.well-known/openid-configuration", "scopes": ["openid", "profile", "email"] } ]' ``` -------------------------------- ### Get Document Statistics Source: https://context7.com/papra-hq/papra/llms.txt Returns aggregate statistics for an organization's documents, including counts and sizes. Requires a valid Authorization header. ```bash curl "https://api.papra.app/api/organizations/org_abc123/documents/statistics" \ -H "Authorization: Bearer ppapi_..." ``` -------------------------------- ### Storage Key Pattern Syntax with Transformers Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/09-storage-key-patterns.mdx Illustrates the general syntax for a storage key pattern expression, including the use of pipes to apply transformers to expression values. Transformers can accept arguments. ```plaintext {{expression | transformer1 | transformer2 arg1 arg2}} ``` -------------------------------- ### Organize by Date Source: https://github.com/papra-hq/papra/blob/main/apps/docs/src/content/docs/03-guides/09-storage-key-patterns.mdx Organizes files by year and month, followed by the document name. ```bash DOCUMENT_STORAGE_KEY_PATTERN={{currentDate.yyyy}}/{{currentDate.MM}}/{{document.name}} # Result: 2025/06/invoice-2025.pdf ``` -------------------------------- ### createClient Source: https://context7.com/papra-hq/papra/llms.txt Initializes the Papra API client with an API key, allowing interaction with the Papra API. ```APIDOC ## Initialize API Client ### Description Creates a typed API client bound to an API key. The `forOrganization` helper pre-fills `organizationId` so it doesn't need to be repeated on every call. ### Method `createClient(options: { apiKey: string; apiBaseUrl?: string; })` ### Parameters - **options.apiKey** (string) - Required - Your Papra API key. - **options.apiBaseUrl** (string) - Optional - The base URL for the Papra API. Defaults to `PAPRA_API_URL`. ### Usage ```typescript import { createClient, PAPRA_API_URL } from '@papra/api-sdk'; // Global client const client = createClient({ apiKey: 'ppapi_my_secret_key', apiBaseUrl: PAPRA_API_URL, // default, can point to self-hosted instance }); // Verify key identity const { apiKey } = await client.getCurrentApiKey(); console.log(apiKey.permissions); // ['documents:create', 'documents:read', ...] // List organizations const { organizations } = await client.listOrganizations(); const orgId = organizations[0].id; // Organization-scoped client (avoids repeating orgId) const orgClient = client.forOrganization(orgId); // Upload a document const file = new File([await fs.readFile('./invoice.pdf')], 'invoice.pdf', { type: 'application/pdf' }); const { document } = await orgClient.uploadDocument({ file }); console.log(document.id); // "doc_xyz789" // List and manage tags const { tags } = await orgClient.listTags(); const { tag } = await orgClient.createTag({ name: 'Invoice', color: '#FF5733' }); await orgClient.addTagToDocument({ documentId: document.id, tagId: tag.id }); // Batch trash by search query const { trashedCount } = await orgClient.trashDocumentsBatch({ filter: { query: 'tag:archive created:<2023' }, }); console.log(`Trashed ${trashedCount} old documents`); ``` ```