@llamaindex/llama-cloud 1.8.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +10 -8
  3. package/client.d.mts +4 -6
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +4 -6
  6. package/client.d.ts.map +1 -1
  7. package/client.js +7 -6
  8. package/client.js.map +1 -1
  9. package/client.mjs +7 -6
  10. package/client.mjs.map +1 -1
  11. package/core/pagination.d.mts +0 -23
  12. package/core/pagination.d.mts.map +1 -1
  13. package/core/pagination.d.ts +0 -23
  14. package/core/pagination.d.ts.map +1 -1
  15. package/core/pagination.js +1 -32
  16. package/core/pagination.js.map +1 -1
  17. package/core/pagination.mjs +0 -30
  18. package/core/pagination.mjs.map +1 -1
  19. package/package.json +12 -1
  20. package/resources/beta/batch/batch.d.mts +55 -30
  21. package/resources/beta/batch/batch.d.mts.map +1 -1
  22. package/resources/beta/batch/batch.d.ts +55 -30
  23. package/resources/beta/batch/batch.d.ts.map +1 -1
  24. package/resources/beta/batch/batch.js +14 -11
  25. package/resources/beta/batch/batch.js.map +1 -1
  26. package/resources/beta/batch/batch.mjs +14 -11
  27. package/resources/beta/batch/batch.mjs.map +1 -1
  28. package/resources/beta/batch/job-items.d.mts +36 -13
  29. package/resources/beta/batch/job-items.d.mts.map +1 -1
  30. package/resources/beta/batch/job-items.d.ts +36 -13
  31. package/resources/beta/batch/job-items.d.ts.map +1 -1
  32. package/resources/beta/batch/job-items.js +6 -8
  33. package/resources/beta/batch/job-items.js.map +1 -1
  34. package/resources/beta/batch/job-items.mjs +6 -8
  35. package/resources/beta/batch/job-items.mjs.map +1 -1
  36. package/resources/beta/sheets.d.mts +16 -0
  37. package/resources/beta/sheets.d.mts.map +1 -1
  38. package/resources/beta/sheets.d.ts +16 -0
  39. package/resources/beta/sheets.d.ts.map +1 -1
  40. package/resources/beta/split.d.mts +60 -16
  41. package/resources/beta/split.d.mts.map +1 -1
  42. package/resources/beta/split.d.ts +60 -16
  43. package/resources/beta/split.d.ts.map +1 -1
  44. package/resources/beta/split.js.map +1 -1
  45. package/resources/beta/split.mjs.map +1 -1
  46. package/resources/classifier/jobs.d.mts +12 -3
  47. package/resources/classifier/jobs.d.mts.map +1 -1
  48. package/resources/classifier/jobs.d.ts +12 -3
  49. package/resources/classifier/jobs.d.ts.map +1 -1
  50. package/resources/classify.d.mts +76 -29
  51. package/resources/classify.d.mts.map +1 -1
  52. package/resources/classify.d.ts +76 -29
  53. package/resources/classify.d.ts.map +1 -1
  54. package/resources/classify.js +19 -2
  55. package/resources/classify.js.map +1 -1
  56. package/resources/classify.mjs +19 -2
  57. package/resources/classify.mjs.map +1 -1
  58. package/resources/extract.d.mts +1588 -0
  59. package/resources/extract.d.mts.map +1 -0
  60. package/resources/extract.d.ts +1588 -0
  61. package/resources/extract.d.ts.map +1 -0
  62. package/resources/extract.js +217 -0
  63. package/resources/extract.js.map +1 -0
  64. package/resources/extract.mjs +213 -0
  65. package/resources/extract.mjs.map +1 -0
  66. package/resources/files.d.mts +52 -38
  67. package/resources/files.d.mts.map +1 -1
  68. package/resources/files.d.ts +52 -38
  69. package/resources/files.d.ts.map +1 -1
  70. package/resources/files.js +10 -9
  71. package/resources/files.js.map +1 -1
  72. package/resources/files.mjs +10 -9
  73. package/resources/files.mjs.map +1 -1
  74. package/resources/index.d.mts +1 -1
  75. package/resources/index.d.mts.map +1 -1
  76. package/resources/index.d.ts +1 -1
  77. package/resources/index.d.ts.map +1 -1
  78. package/resources/index.js +3 -3
  79. package/resources/index.js.map +1 -1
  80. package/resources/index.mjs +1 -1
  81. package/resources/index.mjs.map +1 -1
  82. package/resources/parsing.d.mts +292 -138
  83. package/resources/parsing.d.mts.map +1 -1
  84. package/resources/parsing.d.ts +292 -138
  85. package/resources/parsing.d.ts.map +1 -1
  86. package/resources/parsing.js +30 -4
  87. package/resources/parsing.js.map +1 -1
  88. package/resources/parsing.mjs +30 -4
  89. package/resources/parsing.mjs.map +1 -1
  90. package/resources/pipelines/pipelines.d.mts +59 -13
  91. package/resources/pipelines/pipelines.d.mts.map +1 -1
  92. package/resources/pipelines/pipelines.d.ts +59 -13
  93. package/resources/pipelines/pipelines.d.ts.map +1 -1
  94. package/resources/pipelines/pipelines.js +24 -9
  95. package/resources/pipelines/pipelines.js.map +1 -1
  96. package/resources/pipelines/pipelines.mjs +24 -9
  97. package/resources/pipelines/pipelines.mjs.map +1 -1
  98. package/resources/pipelines/sync.d.mts +5 -3
  99. package/resources/pipelines/sync.d.mts.map +1 -1
  100. package/resources/pipelines/sync.d.ts +5 -3
  101. package/resources/pipelines/sync.d.ts.map +1 -1
  102. package/resources/pipelines/sync.js +5 -3
  103. package/resources/pipelines/sync.js.map +1 -1
  104. package/resources/pipelines/sync.mjs +5 -3
  105. package/resources/pipelines/sync.mjs.map +1 -1
  106. package/src/client.ts +50 -15
  107. package/src/core/pagination.ts +0 -71
  108. package/src/resources/beta/batch/batch.ts +75 -30
  109. package/src/resources/beta/batch/job-items.ts +56 -13
  110. package/src/resources/beta/sheets.ts +20 -0
  111. package/src/resources/beta/split.ts +70 -17
  112. package/src/resources/classifier/jobs.ts +12 -3
  113. package/src/resources/classify.ts +82 -29
  114. package/src/resources/extract.ts +2045 -0
  115. package/src/resources/files.ts +52 -38
  116. package/src/resources/index.ts +22 -1
  117. package/src/resources/parsing.ts +323 -136
  118. package/src/resources/pipelines/pipelines.ts +80 -14
  119. package/src/resources/pipelines/sync.ts +5 -3
  120. package/src/version.ts +1 -1
  121. package/version.d.mts +1 -1
  122. package/version.d.ts +1 -1
  123. package/version.js +1 -1
  124. package/version.mjs +1 -1
  125. package/resources/extraction/extraction-agents/extraction-agents.d.mts +0 -126
  126. package/resources/extraction/extraction-agents/extraction-agents.d.mts.map +0 -1
  127. package/resources/extraction/extraction-agents/extraction-agents.d.ts +0 -126
  128. package/resources/extraction/extraction-agents/extraction-agents.d.ts.map +0 -1
  129. package/resources/extraction/extraction-agents/extraction-agents.js +0 -56
  130. package/resources/extraction/extraction-agents/extraction-agents.js.map +0 -1
  131. package/resources/extraction/extraction-agents/extraction-agents.mjs +0 -51
  132. package/resources/extraction/extraction-agents/extraction-agents.mjs.map +0 -1
  133. package/resources/extraction/extraction-agents/index.d.mts +0 -3
  134. package/resources/extraction/extraction-agents/index.d.mts.map +0 -1
  135. package/resources/extraction/extraction-agents/index.d.ts +0 -3
  136. package/resources/extraction/extraction-agents/index.d.ts.map +0 -1
  137. package/resources/extraction/extraction-agents/index.js +0 -9
  138. package/resources/extraction/extraction-agents/index.js.map +0 -1
  139. package/resources/extraction/extraction-agents/index.mjs +0 -4
  140. package/resources/extraction/extraction-agents/index.mjs.map +0 -1
  141. package/resources/extraction/extraction-agents/schema.d.mts +0 -75
  142. package/resources/extraction/extraction-agents/schema.d.mts.map +0 -1
  143. package/resources/extraction/extraction-agents/schema.d.ts +0 -75
  144. package/resources/extraction/extraction-agents/schema.d.ts.map +0 -1
  145. package/resources/extraction/extraction-agents/schema.js +0 -28
  146. package/resources/extraction/extraction-agents/schema.js.map +0 -1
  147. package/resources/extraction/extraction-agents/schema.mjs +0 -24
  148. package/resources/extraction/extraction-agents/schema.mjs.map +0 -1
  149. package/resources/extraction/extraction-agents.d.mts +0 -2
  150. package/resources/extraction/extraction-agents.d.mts.map +0 -1
  151. package/resources/extraction/extraction-agents.d.ts +0 -2
  152. package/resources/extraction/extraction-agents.d.ts.map +0 -1
  153. package/resources/extraction/extraction-agents.js +0 -6
  154. package/resources/extraction/extraction-agents.js.map +0 -1
  155. package/resources/extraction/extraction-agents.mjs +0 -3
  156. package/resources/extraction/extraction-agents.mjs.map +0 -1
  157. package/resources/extraction/extraction.d.mts +0 -118
  158. package/resources/extraction/extraction.d.mts.map +0 -1
  159. package/resources/extraction/extraction.d.ts +0 -118
  160. package/resources/extraction/extraction.d.ts.map +0 -1
  161. package/resources/extraction/extraction.js +0 -91
  162. package/resources/extraction/extraction.js.map +0 -1
  163. package/resources/extraction/extraction.mjs +0 -86
  164. package/resources/extraction/extraction.mjs.map +0 -1
  165. package/resources/extraction/index.d.mts +0 -5
  166. package/resources/extraction/index.d.mts.map +0 -1
  167. package/resources/extraction/index.d.ts +0 -5
  168. package/resources/extraction/index.d.ts.map +0 -1
  169. package/resources/extraction/index.js +0 -13
  170. package/resources/extraction/index.js.map +0 -1
  171. package/resources/extraction/index.mjs +0 -6
  172. package/resources/extraction/index.mjs.map +0 -1
  173. package/resources/extraction/jobs.d.mts +0 -280
  174. package/resources/extraction/jobs.d.mts.map +0 -1
  175. package/resources/extraction/jobs.d.ts +0 -280
  176. package/resources/extraction/jobs.d.ts.map +0 -1
  177. package/resources/extraction/jobs.js +0 -179
  178. package/resources/extraction/jobs.js.map +0 -1
  179. package/resources/extraction/jobs.mjs +0 -175
  180. package/resources/extraction/jobs.mjs.map +0 -1
  181. package/resources/extraction/runs.d.mts +0 -198
  182. package/resources/extraction/runs.d.mts.map +0 -1
  183. package/resources/extraction/runs.d.ts +0 -198
  184. package/resources/extraction/runs.d.ts.map +0 -1
  185. package/resources/extraction/runs.js +0 -42
  186. package/resources/extraction/runs.js.map +0 -1
  187. package/resources/extraction/runs.mjs +0 -38
  188. package/resources/extraction/runs.mjs.map +0 -1
  189. package/resources/extraction.d.mts +0 -2
  190. package/resources/extraction.d.mts.map +0 -1
  191. package/resources/extraction.d.ts +0 -2
  192. package/resources/extraction.d.ts.map +0 -1
  193. package/resources/extraction.js +0 -6
  194. package/resources/extraction.js.map +0 -1
  195. package/resources/extraction.mjs +0 -3
  196. package/resources/extraction.mjs.map +0 -1
  197. package/src/resources/extraction/extraction-agents/extraction-agents.ts +0 -196
  198. package/src/resources/extraction/extraction-agents/index.ts +0 -18
  199. package/src/resources/extraction/extraction-agents/schema.ts +0 -100
  200. package/src/resources/extraction/extraction-agents.ts +0 -3
  201. package/src/resources/extraction/extraction.ts +0 -224
  202. package/src/resources/extraction/index.ts +0 -34
  203. package/src/resources/extraction/jobs.ts +0 -414
  204. package/src/resources/extraction/runs.ts +0 -315
  205. package/src/resources/extraction.ts +0 -3
@@ -0,0 +1,2045 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as ExtractAPI from './extract';
5
+ import * as ParsingAPI from './parsing';
6
+ import * as SplitAPI from './beta/split';
7
+ import { APIPromise } from '../core/api-promise';
8
+ import { PagePromise, PaginatedCursor, type PaginatedCursorParams } from '../core/pagination';
9
+ import { RequestOptions } from '../internal/request-options';
10
+ import { path } from '../internal/utils/path';
11
+ import { pollUntilComplete, PollingOptions, DEFAULT_TIMEOUT } from '../core/polling';
12
+
13
+ export class Extract extends APIResource {
14
+ /**
15
+ * Create an extraction job.
16
+ *
17
+ * Extracts structured data from a document using either a saved configuration or
18
+ * an inline JSON Schema.
19
+ *
20
+ * ## Input
21
+ *
22
+ * Provide exactly one of:
23
+ *
24
+ * - `configuration_id` — reference a saved extraction config
25
+ * - `configuration` — inline configuration with a `data_schema`
26
+ *
27
+ * ## Document input
28
+ *
29
+ * Set `document_input_value` to a file ID (`dfl-...`) or a completed parse job ID
30
+ * (`pjb-...`).
31
+ *
32
+ * The job runs asynchronously. Poll `GET /extract/{job_id}` or register a webhook
33
+ * to monitor completion.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const extractV2Job = await client.extract.create({
38
+ * document_input_value:
39
+ * 'dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
40
+ * });
41
+ * ```
42
+ */
43
+ create(params: ExtractCreateParams, options?: RequestOptions): APIPromise<ExtractV2Job> {
44
+ const { organization_id, project_id, ...body } = params;
45
+ return this._client.post('/api/v2/extract', { query: { organization_id, project_id }, body, ...options });
46
+ }
47
+
48
+ /**
49
+ * List extraction jobs with optional filtering and pagination.
50
+ *
51
+ * Filter by `configuration_id`, `status`, `document_input_value`, or creation date
52
+ * range. Results are returned newest-first. Use `expand=configuration` to include
53
+ * the full configuration used, and `expand=extract_metadata` for per-field
54
+ * metadata.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * // Automatically fetches more pages as needed.
59
+ * for await (const extractV2Job of client.extract.list()) {
60
+ * // ...
61
+ * }
62
+ * ```
63
+ */
64
+ list(
65
+ query: ExtractListParams | null | undefined = {},
66
+ options?: RequestOptions,
67
+ ): PagePromise<ExtractV2JobsPaginatedCursor, ExtractV2Job> {
68
+ return this._client.getAPIList('/api/v2/extract', PaginatedCursor<ExtractV2Job>, { query, ...options });
69
+ }
70
+
71
+ /**
72
+ * Delete an extraction job and its results.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * const extract = await client.extract.delete('job_id');
77
+ * ```
78
+ */
79
+ delete(
80
+ jobID: string,
81
+ params: ExtractDeleteParams | null | undefined = {},
82
+ options?: RequestOptions,
83
+ ): APIPromise<unknown> {
84
+ const { organization_id, project_id } = params ?? {};
85
+ return this._client.delete(path`/api/v2/extract/${jobID}`, {
86
+ query: { organization_id, project_id },
87
+ ...options,
88
+ });
89
+ }
90
+
91
+ /**
92
+ * Generate a JSON schema and return a product configuration request.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * const response = await client.extract.generateSchema();
97
+ * ```
98
+ */
99
+ generateSchema(
100
+ params: ExtractGenerateSchemaParams,
101
+ options?: RequestOptions,
102
+ ): APIPromise<ExtractGenerateSchemaResponse> {
103
+ const { organization_id, project_id, ...body } = params;
104
+ return this._client.post('/api/v2/extract/schema/generate', {
105
+ query: { organization_id, project_id },
106
+ body,
107
+ ...options,
108
+ });
109
+ }
110
+
111
+ /**
112
+ * Get a single extraction job by ID.
113
+ *
114
+ * Returns the job status and results when complete. Use `expand=configuration` to
115
+ * include the full configuration used, and `expand=extract_metadata` for per-field
116
+ * metadata.
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * const extractV2Job = await client.extract.get('job_id');
121
+ * ```
122
+ */
123
+ get(
124
+ jobID: string,
125
+ query: ExtractGetParams | null | undefined = {},
126
+ options?: RequestOptions,
127
+ ): APIPromise<ExtractV2Job> {
128
+ return this._client.get(path`/api/v2/extract/${jobID}`, { query, ...options });
129
+ }
130
+
131
+ /**
132
+ * Validate a JSON schema for extraction.
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * const extractV2SchemaValidateResponse =
137
+ * await client.extract.validateSchema({
138
+ * data_schema: { foo: { foo: 'bar' } },
139
+ * });
140
+ * ```
141
+ */
142
+ validateSchema(
143
+ body: ExtractValidateSchemaParams,
144
+ options?: RequestOptions,
145
+ ): APIPromise<ExtractV2SchemaValidateResponse> {
146
+ return this._client.post('/api/v2/extract/schema/validation', { body, ...options });
147
+ }
148
+
149
+ /**
150
+ * Wait for an extraction job to complete by polling until it reaches a terminal state.
151
+ *
152
+ * @param jobID - The ID of the extraction job to wait for
153
+ * @param query - Optional query parameters (organization_id, project_id)
154
+ * @param options - Polling configuration and request options
155
+ * @returns The completed extraction job
156
+ * @throws {PollingTimeoutError} If the job doesn't complete within the timeout period
157
+ * @throws {PollingError} If the job fails or is cancelled
158
+ *
159
+ * @example
160
+ * ```typescript
161
+ * const job = await client.extract.create({
162
+ * document_input_value: 'dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
163
+ * });
164
+ *
165
+ * const completed = await client.extract.waitForCompletion(job.id, undefined, { verbose: true });
166
+ * console.log(completed.extract_result);
167
+ * ```
168
+ */
169
+ async waitForCompletion(
170
+ jobID: string,
171
+ query?: ExtractGetParams,
172
+ options?: PollingOptions & RequestOptions,
173
+ ): Promise<ExtractV2Job> {
174
+ const { pollingInterval, maxInterval, timeout, backoff, verbose, ...requestOptions } = options || {};
175
+
176
+ const getStatus = async (): Promise<ExtractV2Job> => {
177
+ return await this.get(jobID, query, requestOptions);
178
+ };
179
+
180
+ const isComplete = (job: ExtractV2Job): boolean => {
181
+ return job.status === 'COMPLETED';
182
+ };
183
+
184
+ const isError = (job: ExtractV2Job): boolean => {
185
+ return job.status === 'FAILED' || job.status === 'CANCELLED';
186
+ };
187
+
188
+ const getErrorMessage = (job: ExtractV2Job): string => {
189
+ const errorParts = [`Job ${jobID} failed with status: ${job.status}`];
190
+ if (job.error_message) {
191
+ errorParts.push(`Error: ${job.error_message}`);
192
+ }
193
+ return errorParts.join(' | ');
194
+ };
195
+
196
+ return await pollUntilComplete(getStatus, isComplete, isError, getErrorMessage, {
197
+ pollingInterval,
198
+ maxInterval,
199
+ timeout: timeout || DEFAULT_TIMEOUT,
200
+ backoff,
201
+ verbose,
202
+ });
203
+ }
204
+
205
+ /**
206
+ * Create an extraction job, wait for it to complete, and return the result.
207
+ *
208
+ * This is a convenience method that combines create() and waitForCompletion()
209
+ * into a single call for the most common end-to-end workflow.
210
+ *
211
+ * @param params - Extract job creation parameters
212
+ * @param options - Polling configuration and request options
213
+ * @returns The completed extraction job with extract_result populated
214
+ * @throws {PollingTimeoutError} If the job doesn't complete within the timeout period
215
+ * @throws {PollingError} If the job fails or is cancelled
216
+ *
217
+ * @example
218
+ * ```typescript
219
+ * import { LlamaCloud } from 'llama-cloud';
220
+ *
221
+ * const client = new LlamaCloud({ apiKey: '...' });
222
+ *
223
+ * const result = await client.extract.run({
224
+ * document_input_value: 'dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
225
+ * configuration: {
226
+ * data_schema: { name: { type: 'string' }, age: { type: 'number' } },
227
+ * },
228
+ * }, { verbose: true });
229
+ *
230
+ * console.log(result.extract_result);
231
+ * ```
232
+ */
233
+ async run(params: ExtractCreateParams, options?: PollingOptions & RequestOptions): Promise<ExtractV2Job> {
234
+ const { pollingInterval, maxInterval, timeout, backoff, verbose, ...requestOptions } = options || {};
235
+
236
+ const job = await this.create(params, requestOptions);
237
+
238
+ const getQuery: ExtractGetParams = {};
239
+ if (params.organization_id !== undefined) {
240
+ getQuery.organization_id = params.organization_id;
241
+ }
242
+ if (params.project_id !== undefined) {
243
+ getQuery.project_id = params.project_id;
244
+ }
245
+
246
+ return await this.waitForCompletion(job.id, getQuery, {
247
+ pollingInterval,
248
+ maxInterval,
249
+ timeout: timeout || DEFAULT_TIMEOUT,
250
+ backoff,
251
+ verbose,
252
+ ...requestOptions,
253
+ });
254
+ }
255
+ }
256
+
257
+ export type ExtractV2JobsPaginatedCursor = PaginatedCursor<ExtractV2Job>;
258
+
259
+ /**
260
+ * Extract configuration combining parse and extract settings.
261
+ */
262
+ export interface ExtractConfiguration {
263
+ /**
264
+ * JSON Schema defining the fields to extract. Validate with the /schema/validate
265
+ * endpoint first.
266
+ */
267
+ data_schema: {
268
+ [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null;
269
+ };
270
+
271
+ /**
272
+ * Include citations in results
273
+ */
274
+ cite_sources?: boolean;
275
+
276
+ /**
277
+ * Include confidence scores in results
278
+ */
279
+ confidence_scores?: boolean;
280
+
281
+ /**
282
+ * Extract algorithm version. Use 'latest' or a date string.
283
+ */
284
+ extract_version?: string;
285
+
286
+ /**
287
+ * Granularity of extraction: per_doc returns one object per document, per_page
288
+ * returns one object per page, per_table_row returns one object per table row
289
+ */
290
+ extraction_target?: 'per_doc' | 'per_page' | 'per_table_row';
291
+
292
+ /**
293
+ * ISO 639-1 language code for the document
294
+ */
295
+ lang?: string;
296
+
297
+ /**
298
+ * Maximum number of pages to process. Omit for no limit.
299
+ */
300
+ max_pages?: number | null;
301
+
302
+ /**
303
+ * Saved parse configuration ID to control how the document is parsed before
304
+ * extraction
305
+ */
306
+ parse_config_id?: string | null;
307
+
308
+ /**
309
+ * Parse tier to use before extraction (fast, cost_effective, or agentic)
310
+ */
311
+ parse_tier?: string | null;
312
+
313
+ /**
314
+ * Custom system prompt to guide extraction behavior
315
+ */
316
+ system_prompt?: string | null;
317
+
318
+ /**
319
+ * Comma-separated page numbers or ranges to process (1-based). Omit to process all
320
+ * pages.
321
+ */
322
+ target_pages?: string | null;
323
+
324
+ /**
325
+ * Extract tier: cost_effective (5 credits/page) or agentic (15 credits/page)
326
+ */
327
+ tier?: 'cost_effective' | 'agentic';
328
+ }
329
+
330
+ /**
331
+ * Extraction metadata.
332
+ */
333
+ export interface ExtractJobMetadata {
334
+ /**
335
+ * Metadata for extracted fields including document, page, and row level info.
336
+ */
337
+ field_metadata?: ExtractedFieldMetadata | null;
338
+
339
+ /**
340
+ * Reference to the ParseJob ID used for parsing
341
+ */
342
+ parse_job_id?: string | null;
343
+
344
+ /**
345
+ * Parse tier used for parsing the document
346
+ */
347
+ parse_tier?: string | null;
348
+ }
349
+
350
+ /**
351
+ * Extraction usage metrics.
352
+ */
353
+ export interface ExtractJobUsage {
354
+ /**
355
+ * Number of document tokens
356
+ */
357
+ num_document_tokens?: number | null;
358
+
359
+ /**
360
+ * Number of output tokens
361
+ */
362
+ num_output_tokens?: number | null;
363
+
364
+ /**
365
+ * Number of pages extracted
366
+ */
367
+ num_pages_extracted?: number | null;
368
+ }
369
+
370
+ /**
371
+ * An extraction job.
372
+ */
373
+ export interface ExtractV2Job {
374
+ /**
375
+ * Unique job identifier (job_id)
376
+ */
377
+ id: string;
378
+
379
+ /**
380
+ * Creation timestamp
381
+ */
382
+ created_at: string;
383
+
384
+ /**
385
+ * File ID or parse job ID that was extracted
386
+ */
387
+ document_input_value: string;
388
+
389
+ /**
390
+ * Project this job belongs to
391
+ */
392
+ project_id: string;
393
+
394
+ /**
395
+ * Current job status.
396
+ *
397
+ * - `PENDING` — queued, not yet started
398
+ * - `RUNNING` — actively processing
399
+ * - `COMPLETED` — finished successfully
400
+ * - `FAILED` — terminated with an error
401
+ * - `CANCELLED` — cancelled by user
402
+ */
403
+ status: string;
404
+
405
+ /**
406
+ * Last update timestamp
407
+ */
408
+ updated_at: string;
409
+
410
+ /**
411
+ * Extract configuration combining parse and extract settings.
412
+ */
413
+ configuration?: ExtractConfiguration | null;
414
+
415
+ /**
416
+ * Saved extract configuration ID used for this job, if any
417
+ */
418
+ configuration_id?: string | null;
419
+
420
+ /**
421
+ * Error details when status is FAILED
422
+ */
423
+ error_message?: string | null;
424
+
425
+ /**
426
+ * Extraction metadata.
427
+ */
428
+ extract_metadata?: ExtractJobMetadata | null;
429
+
430
+ /**
431
+ * Extracted data conforming to the data_schema. Returns a single object for
432
+ * per_doc, or an array for per_page / per_table_row.
433
+ */
434
+ extract_result?:
435
+ | { [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null }
436
+ | Array<{ [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null }>
437
+ | null;
438
+
439
+ /**
440
+ * Job-level metadata.
441
+ */
442
+ metadata?: ExtractV2Job.Metadata | null;
443
+ }
444
+
445
+ export namespace ExtractV2Job {
446
+ /**
447
+ * Job-level metadata.
448
+ */
449
+ export interface Metadata {
450
+ /**
451
+ * Extraction usage metrics.
452
+ */
453
+ usage?: ExtractAPI.ExtractJobUsage | null;
454
+
455
+ [k: string]: unknown;
456
+ }
457
+ }
458
+
459
+ /**
460
+ * Request to create an extraction job. Provide configuration_id or inline
461
+ * configuration.
462
+ */
463
+ export interface ExtractV2JobCreate {
464
+ /**
465
+ * File ID or Parse Job ID to extract from
466
+ */
467
+ document_input_value: string;
468
+
469
+ /**
470
+ * Extract configuration combining parse and extract settings.
471
+ */
472
+ configuration?: ExtractConfiguration | null;
473
+
474
+ /**
475
+ * Saved extract configuration ID (mutually exclusive with configuration)
476
+ */
477
+ configuration_id?: string | null;
478
+
479
+ /**
480
+ * Outbound webhook endpoints to notify on job status changes
481
+ */
482
+ webhook_configurations?: Array<ExtractV2JobCreate.WebhookConfiguration> | null;
483
+ }
484
+
485
+ export namespace ExtractV2JobCreate {
486
+ /**
487
+ * Configuration for a single outbound webhook endpoint.
488
+ */
489
+ export interface WebhookConfiguration {
490
+ /**
491
+ * Events to subscribe to (e.g. 'parse.success', 'extract.error'). If null, all
492
+ * events are delivered.
493
+ */
494
+ webhook_events?: Array<
495
+ | 'extract.pending'
496
+ | 'extract.success'
497
+ | 'extract.error'
498
+ | 'extract.partial_success'
499
+ | 'extract.cancelled'
500
+ | 'parse.pending'
501
+ | 'parse.running'
502
+ | 'parse.success'
503
+ | 'parse.error'
504
+ | 'parse.partial_success'
505
+ | 'parse.cancelled'
506
+ | 'classify.pending'
507
+ | 'classify.success'
508
+ | 'classify.error'
509
+ | 'classify.partial_success'
510
+ | 'classify.cancelled'
511
+ | 'unmapped_event'
512
+ > | null;
513
+
514
+ /**
515
+ * Custom HTTP headers sent with each webhook request (e.g. auth tokens)
516
+ */
517
+ webhook_headers?: { [key: string]: string } | null;
518
+
519
+ /**
520
+ * Response format sent to the webhook: 'string' (default) or 'json'
521
+ */
522
+ webhook_output_format?: string | null;
523
+
524
+ /**
525
+ * URL to receive webhook POST notifications
526
+ */
527
+ webhook_url?: string | null;
528
+ }
529
+ }
530
+
531
+ /**
532
+ * Paginated list of extraction jobs.
533
+ */
534
+ export interface ExtractV2JobQueryResponse {
535
+ /**
536
+ * The list of items.
537
+ */
538
+ items: Array<ExtractV2Job>;
539
+
540
+ /**
541
+ * A token, which can be sent as page_token to retrieve the next page. If this
542
+ * field is omitted, there are no subsequent pages.
543
+ */
544
+ next_page_token?: string | null;
545
+
546
+ /**
547
+ * The total number of items available. This is only populated when specifically
548
+ * requested. The value may be an estimate and can be used for display purposes
549
+ * only.
550
+ */
551
+ total_size?: number | null;
552
+ }
553
+
554
+ /**
555
+ * Request schema for generating an extraction schema.
556
+ */
557
+ export interface ExtractV2SchemaGenerateRequest {
558
+ /**
559
+ * Optional schema to validate, refine, or extend
560
+ */
561
+ data_schema?: {
562
+ [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null;
563
+ } | null;
564
+
565
+ /**
566
+ * Optional file ID to analyze for schema generation
567
+ */
568
+ file_id?: string | null;
569
+
570
+ /**
571
+ * Name for the generated configuration (auto-generated if omitted)
572
+ */
573
+ name?: string | null;
574
+
575
+ /**
576
+ * Natural language description of the data structure to extract
577
+ */
578
+ prompt?: string | null;
579
+ }
580
+
581
+ /**
582
+ * Request schema for validating an extraction schema.
583
+ */
584
+ export interface ExtractV2SchemaValidateRequest {
585
+ /**
586
+ * JSON Schema to validate for use with extract jobs
587
+ */
588
+ data_schema: {
589
+ [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null;
590
+ };
591
+ }
592
+
593
+ /**
594
+ * Response schema for schema validation.
595
+ */
596
+ export interface ExtractV2SchemaValidateResponse {
597
+ /**
598
+ * Validated JSON Schema, ready for use in extract jobs
599
+ */
600
+ data_schema: {
601
+ [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null;
602
+ };
603
+ }
604
+
605
+ /**
606
+ * Metadata for extracted fields including document, page, and row level info.
607
+ */
608
+ export interface ExtractedFieldMetadata {
609
+ /**
610
+ * Document-level metadata (citations, confidence) keyed by field name
611
+ */
612
+ document_metadata?: {
613
+ [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null;
614
+ } | null;
615
+
616
+ /**
617
+ * Per-page metadata when extraction_target is per_page
618
+ */
619
+ page_metadata?: Array<{
620
+ [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null;
621
+ }> | null;
622
+
623
+ /**
624
+ * Per-row metadata when extraction_target is per_table_row
625
+ */
626
+ row_metadata?: Array<{
627
+ [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null;
628
+ }> | null;
629
+ }
630
+
631
+ export type ExtractDeleteResponse = unknown;
632
+
633
+ /**
634
+ * Request body for creating a product configuration.
635
+ */
636
+ export interface ExtractGenerateSchemaResponse {
637
+ /**
638
+ * Human-readable name for this configuration.
639
+ */
640
+ name: string;
641
+
642
+ /**
643
+ * Product-specific configuration parameters.
644
+ */
645
+ parameters:
646
+ | ExtractGenerateSchemaResponse.SplitV1Parameters
647
+ | ExtractGenerateSchemaResponse.ExtractV2Parameters
648
+ | ExtractGenerateSchemaResponse.ClassifyV2Parameters
649
+ | ExtractGenerateSchemaResponse.ParseV2Parameters
650
+ | ExtractGenerateSchemaResponse.UntypedParameters;
651
+ }
652
+
653
+ export namespace ExtractGenerateSchemaResponse {
654
+ /**
655
+ * Typed parameters for a _split v1_ product configuration.
656
+ */
657
+ export interface SplitV1Parameters {
658
+ /**
659
+ * Categories to split documents into.
660
+ */
661
+ categories: Array<SplitAPI.SplitCategory>;
662
+
663
+ /**
664
+ * Product type.
665
+ */
666
+ product_type: 'split_v1';
667
+
668
+ /**
669
+ * Strategy for splitting documents.
670
+ */
671
+ splitting_strategy?: SplitV1Parameters.SplittingStrategy;
672
+ }
673
+
674
+ export namespace SplitV1Parameters {
675
+ /**
676
+ * Strategy for splitting documents.
677
+ */
678
+ export interface SplittingStrategy {
679
+ /**
680
+ * Controls handling of pages that don't match any category. 'include': pages can
681
+ * be grouped as 'uncategorized' and included in results. 'forbid': all pages must
682
+ * be assigned to a defined category. 'omit': pages can be classified as
683
+ * 'uncategorized' but are excluded from results.
684
+ */
685
+ allow_uncategorized?: 'include' | 'forbid' | 'omit';
686
+ }
687
+ }
688
+
689
+ /**
690
+ * Typed parameters for an _extract v2_ product configuration.
691
+ */
692
+ export interface ExtractV2Parameters {
693
+ /**
694
+ * JSON Schema defining the fields to extract. Validate with the /schema/validate
695
+ * endpoint first.
696
+ */
697
+ data_schema: {
698
+ [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null;
699
+ };
700
+
701
+ /**
702
+ * Product type.
703
+ */
704
+ product_type: 'extract_v2';
705
+
706
+ /**
707
+ * Include citations in results
708
+ */
709
+ cite_sources?: boolean;
710
+
711
+ /**
712
+ * Include confidence scores in results
713
+ */
714
+ confidence_scores?: boolean;
715
+
716
+ /**
717
+ * Extract algorithm version. Use 'latest' or a date string.
718
+ */
719
+ extract_version?: string;
720
+
721
+ /**
722
+ * Granularity of extraction: per_doc returns one object per document, per_page
723
+ * returns one object per page, per_table_row returns one object per table row
724
+ */
725
+ extraction_target?: 'per_doc' | 'per_page' | 'per_table_row';
726
+
727
+ /**
728
+ * ISO 639-1 language code for the document
729
+ */
730
+ lang?: string;
731
+
732
+ /**
733
+ * Maximum number of pages to process. Omit for no limit.
734
+ */
735
+ max_pages?: number | null;
736
+
737
+ /**
738
+ * Saved parse configuration ID to control how the document is parsed before
739
+ * extraction
740
+ */
741
+ parse_config_id?: string | null;
742
+
743
+ /**
744
+ * Parse tier to use before extraction (fast, cost_effective, or agentic)
745
+ */
746
+ parse_tier?: string | null;
747
+
748
+ /**
749
+ * Custom system prompt to guide extraction behavior
750
+ */
751
+ system_prompt?: string | null;
752
+
753
+ /**
754
+ * Comma-separated page numbers or ranges to process (1-based). Omit to process all
755
+ * pages.
756
+ */
757
+ target_pages?: string | null;
758
+
759
+ /**
760
+ * Extract tier: cost_effective (5 credits/page) or agentic (15 credits/page)
761
+ */
762
+ tier?: 'cost_effective' | 'agentic';
763
+ }
764
+
765
+ /**
766
+ * Typed parameters for a _classify v2_ product configuration.
767
+ */
768
+ export interface ClassifyV2Parameters {
769
+ /**
770
+ * Product type.
771
+ */
772
+ product_type: 'classify_v2';
773
+
774
+ /**
775
+ * Classify rules to evaluate against the document (at least one required)
776
+ */
777
+ rules: Array<ClassifyV2Parameters.Rule>;
778
+
779
+ /**
780
+ * Classify execution mode
781
+ */
782
+ mode?: 'FAST';
783
+
784
+ /**
785
+ * Parsing configuration for classify jobs.
786
+ */
787
+ parsing_configuration?: ClassifyV2Parameters.ParsingConfiguration | null;
788
+ }
789
+
790
+ export namespace ClassifyV2Parameters {
791
+ /**
792
+ * A rule for classifying documents.
793
+ */
794
+ export interface Rule {
795
+ /**
796
+ * Natural language criteria for matching this rule
797
+ */
798
+ description: string;
799
+
800
+ /**
801
+ * Document type to assign when rule matches
802
+ */
803
+ type: string;
804
+ }
805
+
806
+ /**
807
+ * Parsing configuration for classify jobs.
808
+ */
809
+ export interface ParsingConfiguration {
810
+ /**
811
+ * ISO 639-1 language code for the document
812
+ */
813
+ lang?: string;
814
+
815
+ /**
816
+ * Maximum number of pages to process. Omit for no limit.
817
+ */
818
+ max_pages?: number | null;
819
+
820
+ /**
821
+ * Comma-separated page numbers or ranges to process (1-based). Omit to process all
822
+ * pages.
823
+ */
824
+ target_pages?: string | null;
825
+ }
826
+ }
827
+
828
+ /**
829
+ * Configuration for LlamaParse v2 document parsing.
830
+ *
831
+ * Includes tier selection, processing options, output formatting, page targeting,
832
+ * and webhook delivery. Refer to the LlamaParse documentation for details on each
833
+ * field.
834
+ */
835
+ export interface ParseV2Parameters {
836
+ /**
837
+ * Product type.
838
+ */
839
+ product_type: 'parse_v2';
840
+
841
+ /**
842
+ * Parsing tier: 'fast' (rule-based, cheapest), 'cost_effective' (balanced),
843
+ * 'agentic' (AI-powered with custom prompts), or 'agentic_plus' (premium AI with
844
+ * highest accuracy)
845
+ */
846
+ tier: 'fast' | 'cost_effective' | 'agentic' | 'agentic_plus';
847
+
848
+ /**
849
+ * Tier version. Use 'latest' for the current stable version, or specify a specific
850
+ * version (e.g., '1.0', '2.0') for reproducible results
851
+ */
852
+ version:
853
+ | '2025-12-11'
854
+ | '2025-12-18'
855
+ | '2025-12-31'
856
+ | '2026-01-08'
857
+ | '2026-01-09'
858
+ | '2026-01-16'
859
+ | '2026-01-21'
860
+ | '2026-01-22'
861
+ | '2026-01-24'
862
+ | '2026-01-29'
863
+ | '2026-01-30'
864
+ | '2026-02-03'
865
+ | '2026-02-18'
866
+ | '2026-02-20'
867
+ | '2026-02-24'
868
+ | '2026-02-26'
869
+ | '2026-03-02'
870
+ | '2026-03-03'
871
+ | '2026-03-04'
872
+ | '2026-03-05'
873
+ | '2026-03-09'
874
+ | '2026-03-10'
875
+ | '2026-03-11'
876
+ | '2026-03-12'
877
+ | '2026-03-17'
878
+ | '2026-03-19'
879
+ | '2026-03-20'
880
+ | '2026-03-22'
881
+ | '2026-03-23'
882
+ | '2026-03-24'
883
+ | '2026-03-25'
884
+ | '2026-03-26'
885
+ | '2026-03-27'
886
+ | 'latest'
887
+ | (string & {});
888
+
889
+ /**
890
+ * Options for AI-powered parsing tiers (cost_effective, agentic, agentic_plus).
891
+ *
892
+ * These options customize how the AI processes and interprets document content.
893
+ * Only applicable when using non-fast tiers.
894
+ */
895
+ agentic_options?: ParseV2Parameters.AgenticOptions | null;
896
+
897
+ /**
898
+ * Identifier for the client/application making the request. Used for analytics and
899
+ * debugging. Example: 'my-app-v2'
900
+ */
901
+ client_name?: string | null;
902
+
903
+ /**
904
+ * Crop boundaries to process only a portion of each page. Values are ratios 0-1
905
+ * from page edges
906
+ */
907
+ crop_box?: ParseV2Parameters.CropBox;
908
+
909
+ /**
910
+ * Bypass result caching and force re-parsing. Use when document content may have
911
+ * changed or you need fresh results
912
+ */
913
+ disable_cache?: boolean | null;
914
+
915
+ /**
916
+ * Options for fast tier parsing (rule-based, no AI).
917
+ *
918
+ * Fast tier uses deterministic algorithms for text extraction without AI
919
+ * enhancement. It's the fastest and most cost-effective option, best suited for
920
+ * simple documents with standard layouts. Currently has no configurable options
921
+ * but reserved for future expansion.
922
+ */
923
+ fast_options?: unknown | null;
924
+
925
+ /**
926
+ * Format-specific options (HTML, PDF, spreadsheet, presentation). Applied based on
927
+ * detected input file type
928
+ */
929
+ input_options?: ParseV2Parameters.InputOptions;
930
+
931
+ /**
932
+ * Output formatting options for markdown, text, and extracted images
933
+ */
934
+ output_options?: ParseV2Parameters.OutputOptions;
935
+
936
+ /**
937
+ * Page selection: limit total pages or specify exact pages to process
938
+ */
939
+ page_ranges?: ParseV2Parameters.PageRanges;
940
+
941
+ /**
942
+ * Job execution controls including timeouts and failure thresholds
943
+ */
944
+ processing_control?: ParseV2Parameters.ProcessingControl;
945
+
946
+ /**
947
+ * Document processing options including OCR, table extraction, and chart parsing
948
+ */
949
+ processing_options?: ParseV2Parameters.ProcessingOptions;
950
+
951
+ /**
952
+ * Webhook endpoints for job status notifications. Multiple webhooks can be
953
+ * configured for different events or services
954
+ */
955
+ webhook_configurations?: Array<ParseV2Parameters.WebhookConfiguration>;
956
+ }
957
+
958
+ export namespace ParseV2Parameters {
959
+ /**
960
+ * Options for AI-powered parsing tiers (cost_effective, agentic, agentic_plus).
961
+ *
962
+ * These options customize how the AI processes and interprets document content.
963
+ * Only applicable when using non-fast tiers.
964
+ */
965
+ export interface AgenticOptions {
966
+ /**
967
+ * Custom instructions for the AI parser. Use to guide extraction behavior, specify
968
+ * output formatting, or provide domain-specific context. Example: 'Extract
969
+ * financial tables with currency symbols. Format dates as YYYY-MM-DD.'
970
+ */
971
+ custom_prompt?: string | null;
972
+ }
973
+
974
+ /**
975
+ * Crop boundaries to process only a portion of each page. Values are ratios 0-1
976
+ * from page edges
977
+ */
978
+ export interface CropBox {
979
+ /**
980
+ * Bottom boundary as ratio (0-1). 0=top edge, 1=bottom edge. Content below this
981
+ * line is excluded
982
+ */
983
+ bottom?: number | null;
984
+
985
+ /**
986
+ * Left boundary as ratio (0-1). 0=left edge, 1=right edge. Content left of this
987
+ * line is excluded
988
+ */
989
+ left?: number | null;
990
+
991
+ /**
992
+ * Right boundary as ratio (0-1). 0=left edge, 1=right edge. Content right of this
993
+ * line is excluded
994
+ */
995
+ right?: number | null;
996
+
997
+ /**
998
+ * Top boundary as ratio (0-1). 0=top edge, 1=bottom edge. Content above this line
999
+ * is excluded
1000
+ */
1001
+ top?: number | null;
1002
+ }
1003
+
1004
+ /**
1005
+ * Format-specific options (HTML, PDF, spreadsheet, presentation). Applied based on
1006
+ * detected input file type
1007
+ */
1008
+ export interface InputOptions {
1009
+ /**
1010
+ * HTML/web page parsing options (applies to .html, .htm files)
1011
+ */
1012
+ html?: InputOptions.HTML;
1013
+
1014
+ /**
1015
+ * PDF-specific parsing options (applies to .pdf files)
1016
+ */
1017
+ pdf?: unknown;
1018
+
1019
+ /**
1020
+ * Presentation parsing options (applies to .pptx, .ppt, .odp, .key files)
1021
+ */
1022
+ presentation?: InputOptions.Presentation;
1023
+
1024
+ /**
1025
+ * Spreadsheet parsing options (applies to .xlsx, .xls, .csv, .ods files)
1026
+ */
1027
+ spreadsheet?: InputOptions.Spreadsheet;
1028
+ }
1029
+
1030
+ export namespace InputOptions {
1031
+ /**
1032
+ * HTML/web page parsing options (applies to .html, .htm files)
1033
+ */
1034
+ export interface HTML {
1035
+ /**
1036
+ * Force all HTML elements to be visible by overriding CSS display/visibility
1037
+ * properties. Useful for parsing pages with hidden content or collapsed sections
1038
+ */
1039
+ make_all_elements_visible?: boolean | null;
1040
+
1041
+ /**
1042
+ * Remove fixed-position elements (headers, footers, floating buttons) that appear
1043
+ * on every page render
1044
+ */
1045
+ remove_fixed_elements?: boolean | null;
1046
+
1047
+ /**
1048
+ * Remove navigation elements (nav bars, sidebars, menus) to focus on main content
1049
+ */
1050
+ remove_navigation_elements?: boolean | null;
1051
+ }
1052
+
1053
+ /**
1054
+ * Presentation parsing options (applies to .pptx, .ppt, .odp, .key files)
1055
+ */
1056
+ export interface Presentation {
1057
+ /**
1058
+ * Extract content positioned outside the visible slide area. Some presentations
1059
+ * have hidden notes or content that extends beyond slide boundaries
1060
+ */
1061
+ out_of_bounds_content?: boolean | null;
1062
+
1063
+ /**
1064
+ * Skip extraction of embedded chart data tables. When true, only the visual
1065
+ * representation of charts is captured, not the underlying data
1066
+ */
1067
+ skip_embedded_data?: boolean | null;
1068
+ }
1069
+
1070
+ /**
1071
+ * Spreadsheet parsing options (applies to .xlsx, .xls, .csv, .ods files)
1072
+ */
1073
+ export interface Spreadsheet {
1074
+ /**
1075
+ * Detect and extract multiple tables within a single sheet. Useful when
1076
+ * spreadsheets contain several data regions separated by blank rows/columns
1077
+ */
1078
+ detect_sub_tables_in_sheets?: boolean | null;
1079
+
1080
+ /**
1081
+ * Compute formula results instead of extracting formula text. Use when you need
1082
+ * calculated values rather than formula definitions
1083
+ */
1084
+ force_formula_computation_in_sheets?: boolean | null;
1085
+
1086
+ /**
1087
+ * Parse hidden sheets in addition to visible ones. By default, hidden sheets are
1088
+ * skipped
1089
+ */
1090
+ include_hidden_sheets?: boolean | null;
1091
+ }
1092
+ }
1093
+
1094
+ /**
1095
+ * Output formatting options for markdown, text, and extracted images
1096
+ */
1097
+ export interface OutputOptions {
1098
+ /**
1099
+ * Extract the printed page number as it appears in the document (e.g., 'Page 5 of
1100
+ * 10', 'v', 'A-3'). Useful for referencing original page numbers
1101
+ */
1102
+ extract_printed_page_number?: boolean | null;
1103
+
1104
+ /**
1105
+ * Image categories to extract and save. Options: 'screenshot' (full page renders
1106
+ * useful for visual QA), 'embedded' (images found within the document), 'layout'
1107
+ * (cropped regions from layout detection like figures and diagrams). Empty list
1108
+ * saves no images
1109
+ */
1110
+ images_to_save?: Array<'screenshot' | 'embedded' | 'layout'>;
1111
+
1112
+ /**
1113
+ * Markdown formatting options including table styles and link annotations
1114
+ */
1115
+ markdown?: OutputOptions.Markdown;
1116
+
1117
+ /**
1118
+ * Spatial text output options for preserving document layout structure
1119
+ */
1120
+ spatial_text?: OutputOptions.SpatialText;
1121
+
1122
+ /**
1123
+ * Options for exporting tables as XLSX spreadsheets
1124
+ */
1125
+ tables_as_spreadsheet?: OutputOptions.TablesAsSpreadsheet;
1126
+ }
1127
+
1128
+ export namespace OutputOptions {
1129
+ /**
1130
+ * Markdown formatting options including table styles and link annotations
1131
+ */
1132
+ export interface Markdown {
1133
+ /**
1134
+ * Add link annotations to markdown output in the format [text](url). When false,
1135
+ * only the link text is included
1136
+ */
1137
+ annotate_links?: boolean | null;
1138
+
1139
+ /**
1140
+ * Embed images directly in markdown as base64 data URIs instead of extracting them
1141
+ * as separate files. Useful for self-contained markdown output
1142
+ */
1143
+ inline_images?: boolean | null;
1144
+
1145
+ /**
1146
+ * Table formatting options including markdown vs HTML format and merging behavior
1147
+ */
1148
+ tables?: Markdown.Tables;
1149
+ }
1150
+
1151
+ export namespace Markdown {
1152
+ /**
1153
+ * Table formatting options including markdown vs HTML format and merging behavior
1154
+ */
1155
+ export interface Tables {
1156
+ /**
1157
+ * Remove extra whitespace padding in markdown table cells for more compact output
1158
+ */
1159
+ compact_markdown_tables?: boolean | null;
1160
+
1161
+ /**
1162
+ * Separator string for multiline cell content in markdown tables. Example:
1163
+ * '&lt;br&gt;' to preserve line breaks, ' ' to join with spaces
1164
+ */
1165
+ markdown_table_multiline_separator?: string | null;
1166
+
1167
+ /**
1168
+ * Automatically merge tables that span multiple pages into a single table. The
1169
+ * merged table appears on the first page with merged_from_pages metadata
1170
+ */
1171
+ merge_continued_tables?: boolean | null;
1172
+
1173
+ /**
1174
+ * Output tables as markdown pipe tables instead of HTML &lt;table&gt; tags.
1175
+ * Markdown tables are simpler but cannot represent complex structures like merged
1176
+ * cells
1177
+ */
1178
+ output_tables_as_markdown?: boolean | null;
1179
+ }
1180
+ }
1181
+
1182
+ /**
1183
+ * Spatial text output options for preserving document layout structure
1184
+ */
1185
+ export interface SpatialText {
1186
+ /**
1187
+ * Keep multi-column layouts intact instead of linearizing columns into sequential
1188
+ * text. Automatically enabled for non-fast tiers
1189
+ */
1190
+ do_not_unroll_columns?: boolean | null;
1191
+
1192
+ /**
1193
+ * Maintain consistent text column alignment across page boundaries. Automatically
1194
+ * enabled for document-level parsing modes
1195
+ */
1196
+ preserve_layout_alignment_across_pages?: boolean | null;
1197
+
1198
+ /**
1199
+ * Include text below the normal size threshold. Useful for footnotes, watermarks,
1200
+ * or fine print that might otherwise be filtered out
1201
+ */
1202
+ preserve_very_small_text?: boolean | null;
1203
+ }
1204
+
1205
+ /**
1206
+ * Options for exporting tables as XLSX spreadsheets
1207
+ */
1208
+ export interface TablesAsSpreadsheet {
1209
+ /**
1210
+ * Whether this option is enabled
1211
+ */
1212
+ enable?: boolean | null;
1213
+
1214
+ /**
1215
+ * Automatically generate descriptive sheet names from table context (headers,
1216
+ * surrounding text) instead of using generic names like 'Table_1'
1217
+ */
1218
+ guess_sheet_name?: boolean;
1219
+ }
1220
+ }
1221
+
1222
+ /**
1223
+ * Page selection: limit total pages or specify exact pages to process
1224
+ */
1225
+ export interface PageRanges {
1226
+ /**
1227
+ * Maximum number of pages to process. Pages are processed in order starting from
1228
+ * page 1. If both max_pages and target_pages are set, target_pages takes
1229
+ * precedence
1230
+ */
1231
+ max_pages?: number | null;
1232
+
1233
+ /**
1234
+ * Comma-separated list of specific pages to process using 1-based indexing.
1235
+ * Supports individual pages and ranges. Examples: '1,3,5' (pages 1, 3, 5), '1-5'
1236
+ * (pages 1 through 5 inclusive), '1,3,5-8,10' (pages 1, 3, 5-8, and 10). Pages are
1237
+ * sorted and deduplicated automatically. Duplicate pages cause an error
1238
+ */
1239
+ target_pages?: string | null;
1240
+ }
1241
+
1242
+ /**
1243
+ * Job execution controls including timeouts and failure thresholds
1244
+ */
1245
+ export interface ProcessingControl {
1246
+ /**
1247
+ * Quality thresholds that determine when a job should fail vs complete with
1248
+ * partial results
1249
+ */
1250
+ job_failure_conditions?: ProcessingControl.JobFailureConditions;
1251
+
1252
+ /**
1253
+ * Timeout settings for job execution. Increase for large or complex documents
1254
+ */
1255
+ timeouts?: ProcessingControl.Timeouts;
1256
+ }
1257
+
1258
+ export namespace ProcessingControl {
1259
+ /**
1260
+ * Quality thresholds that determine when a job should fail vs complete with
1261
+ * partial results
1262
+ */
1263
+ export interface JobFailureConditions {
1264
+ /**
1265
+ * Maximum ratio of pages allowed to fail before the job fails (0-1). Example: 0.1
1266
+ * means job fails if more than 10% of pages fail. Default is 0.05 (5%)
1267
+ */
1268
+ allowed_page_failure_ratio?: number | null;
1269
+
1270
+ /**
1271
+ * Fail the job if a problematic font is detected that may cause incorrect text
1272
+ * extraction. Buggy fonts can produce garbled or missing characters
1273
+ */
1274
+ fail_on_buggy_font?: boolean | null;
1275
+
1276
+ /**
1277
+ * Fail the entire job if any embedded image cannot be extracted. By default, image
1278
+ * extraction errors are logged but don't fail the job
1279
+ */
1280
+ fail_on_image_extraction_error?: boolean | null;
1281
+
1282
+ /**
1283
+ * Fail the entire job if OCR fails on any image. By default, OCR errors result in
1284
+ * empty text for that image
1285
+ */
1286
+ fail_on_image_ocr_error?: boolean | null;
1287
+
1288
+ /**
1289
+ * Fail the entire job if markdown cannot be reconstructed for any page. By
1290
+ * default, failed pages use fallback text extraction
1291
+ */
1292
+ fail_on_markdown_reconstruction_error?: boolean | null;
1293
+ }
1294
+
1295
+ /**
1296
+ * Timeout settings for job execution. Increase for large or complex documents
1297
+ */
1298
+ export interface Timeouts {
1299
+ /**
1300
+ * Base timeout for the job in seconds (max 1800 = 30 minutes). This is the minimum
1301
+ * time allowed regardless of document size
1302
+ */
1303
+ base_in_seconds?: number | null;
1304
+
1305
+ /**
1306
+ * Additional timeout per page in seconds (max 300 = 5 minutes). Total timeout =
1307
+ * base + (this value × page count)
1308
+ */
1309
+ extra_time_per_page_in_seconds?: number | null;
1310
+ }
1311
+ }
1312
+
1313
+ /**
1314
+ * Document processing options including OCR, table extraction, and chart parsing
1315
+ */
1316
+ export interface ProcessingOptions {
1317
+ /**
1318
+ * Use aggressive heuristics to detect table boundaries, even without visible
1319
+ * borders. Useful for documents with borderless or complex tables
1320
+ */
1321
+ aggressive_table_extraction?: boolean | null;
1322
+
1323
+ /**
1324
+ * Conditional processing rules that apply different parsing options based on page
1325
+ * content, document structure, or filename patterns. Each entry defines trigger
1326
+ * conditions and the parsing configuration to apply when triggered
1327
+ */
1328
+ auto_mode_configuration?: Array<ProcessingOptions.AutoModeConfiguration> | null;
1329
+
1330
+ /**
1331
+ * Cost optimizer configuration for reducing parsing costs on simpler pages.
1332
+ *
1333
+ * When enabled, the parser analyzes each page and routes simpler pages to faster,
1334
+ * cheaper processing while preserving quality for complex pages. Only works with
1335
+ * 'agentic' or 'agentic_plus' tiers.
1336
+ */
1337
+ cost_optimizer?: ProcessingOptions.CostOptimizer | null;
1338
+
1339
+ /**
1340
+ * Disable automatic heuristics including outlined table extraction and adaptive
1341
+ * long table handling. Use when heuristics produce incorrect results
1342
+ */
1343
+ disable_heuristics?: boolean | null;
1344
+
1345
+ /**
1346
+ * Options for ignoring specific text types (diagonal, hidden, text in images)
1347
+ */
1348
+ ignore?: ProcessingOptions.Ignore;
1349
+
1350
+ /**
1351
+ * OCR configuration including language detection settings
1352
+ */
1353
+ ocr_parameters?: ProcessingOptions.OcrParameters;
1354
+
1355
+ /**
1356
+ * Enable AI-powered chart analysis. Modes: 'efficient' (fast, lower cost),
1357
+ * 'agentic' (balanced), 'agentic_plus' (highest accuracy). Automatically enables
1358
+ * extract_layout and precise_bounding_box when set
1359
+ */
1360
+ specialized_chart_parsing?: 'agentic_plus' | 'agentic' | 'efficient' | null;
1361
+ }
1362
+
1363
+ export namespace ProcessingOptions {
1364
+ /**
1365
+ * A single auto mode rule with trigger conditions and parsing configuration.
1366
+ *
1367
+ * Auto mode allows conditional parsing where different configurations are applied
1368
+ * based on page content, structure, or filename. When triggers match, the
1369
+ * parsing_conf overrides default settings for that page.
1370
+ */
1371
+ export interface AutoModeConfiguration {
1372
+ /**
1373
+ * Parsing configuration to apply when trigger conditions are met
1374
+ */
1375
+ parsing_conf: AutoModeConfiguration.ParsingConf;
1376
+
1377
+ /**
1378
+ * Single glob pattern to match against filename
1379
+ */
1380
+ filename_match_glob?: string | null;
1381
+
1382
+ /**
1383
+ * List of glob patterns to match against filename
1384
+ */
1385
+ filename_match_glob_list?: Array<string> | null;
1386
+
1387
+ /**
1388
+ * Regex pattern to match against filename
1389
+ */
1390
+ filename_regexp?: string | null;
1391
+
1392
+ /**
1393
+ * Regex mode flags (e.g., 'i' for case-insensitive)
1394
+ */
1395
+ filename_regexp_mode?: string | null;
1396
+
1397
+ /**
1398
+ * Trigger if page contains a full-page image (scanned page detection)
1399
+ */
1400
+ full_page_image_in_page?: boolean | null;
1401
+
1402
+ /**
1403
+ * Threshold for full page image detection (0.0-1.0, default 0.8)
1404
+ */
1405
+ full_page_image_in_page_threshold?: number | string | null;
1406
+
1407
+ /**
1408
+ * Trigger if page contains non-screenshot images
1409
+ */
1410
+ image_in_page?: boolean | null;
1411
+
1412
+ /**
1413
+ * Trigger if page contains this layout element type
1414
+ */
1415
+ layout_element_in_page?: string | null;
1416
+
1417
+ /**
1418
+ * Confidence threshold for layout element detection
1419
+ */
1420
+ layout_element_in_page_confidence_threshold?: number | string | null;
1421
+
1422
+ /**
1423
+ * Trigger if page has more than N charts
1424
+ */
1425
+ page_contains_at_least_n_charts?: number | string | null;
1426
+
1427
+ /**
1428
+ * Trigger if page has more than N images
1429
+ */
1430
+ page_contains_at_least_n_images?: number | string | null;
1431
+
1432
+ /**
1433
+ * Trigger if page has more than N layout elements
1434
+ */
1435
+ page_contains_at_least_n_layout_elements?: number | string | null;
1436
+
1437
+ /**
1438
+ * Trigger if page has more than N lines
1439
+ */
1440
+ page_contains_at_least_n_lines?: number | string | null;
1441
+
1442
+ /**
1443
+ * Trigger if page has more than N links
1444
+ */
1445
+ page_contains_at_least_n_links?: number | string | null;
1446
+
1447
+ /**
1448
+ * Trigger if page has more than N numeric words
1449
+ */
1450
+ page_contains_at_least_n_numbers?: number | string | null;
1451
+
1452
+ /**
1453
+ * Trigger if page has more than N% numeric words
1454
+ */
1455
+ page_contains_at_least_n_percent_numbers?: number | string | null;
1456
+
1457
+ /**
1458
+ * Trigger if page has more than N tables
1459
+ */
1460
+ page_contains_at_least_n_tables?: number | string | null;
1461
+
1462
+ /**
1463
+ * Trigger if page has more than N words
1464
+ */
1465
+ page_contains_at_least_n_words?: number | string | null;
1466
+
1467
+ /**
1468
+ * Trigger if page has fewer than N charts
1469
+ */
1470
+ page_contains_at_most_n_charts?: number | string | null;
1471
+
1472
+ /**
1473
+ * Trigger if page has fewer than N images
1474
+ */
1475
+ page_contains_at_most_n_images?: number | string | null;
1476
+
1477
+ /**
1478
+ * Trigger if page has fewer than N layout elements
1479
+ */
1480
+ page_contains_at_most_n_layout_elements?: number | string | null;
1481
+
1482
+ /**
1483
+ * Trigger if page has fewer than N lines
1484
+ */
1485
+ page_contains_at_most_n_lines?: number | string | null;
1486
+
1487
+ /**
1488
+ * Trigger if page has fewer than N links
1489
+ */
1490
+ page_contains_at_most_n_links?: number | string | null;
1491
+
1492
+ /**
1493
+ * Trigger if page has fewer than N numeric words
1494
+ */
1495
+ page_contains_at_most_n_numbers?: number | string | null;
1496
+
1497
+ /**
1498
+ * Trigger if page has fewer than N% numeric words
1499
+ */
1500
+ page_contains_at_most_n_percent_numbers?: number | string | null;
1501
+
1502
+ /**
1503
+ * Trigger if page has fewer than N tables
1504
+ */
1505
+ page_contains_at_most_n_tables?: number | string | null;
1506
+
1507
+ /**
1508
+ * Trigger if page has fewer than N words
1509
+ */
1510
+ page_contains_at_most_n_words?: number | string | null;
1511
+
1512
+ /**
1513
+ * Trigger if page has more than N characters
1514
+ */
1515
+ page_longer_than_n_chars?: number | string | null;
1516
+
1517
+ /**
1518
+ * Trigger on pages with markdown extraction errors
1519
+ */
1520
+ page_md_error?: boolean | null;
1521
+
1522
+ /**
1523
+ * Trigger if page has fewer than N characters
1524
+ */
1525
+ page_shorter_than_n_chars?: number | string | null;
1526
+
1527
+ /**
1528
+ * Regex pattern to match in page content
1529
+ */
1530
+ regexp_in_page?: string | null;
1531
+
1532
+ /**
1533
+ * Regex mode flags for regexp_in_page
1534
+ */
1535
+ regexp_in_page_mode?: string | null;
1536
+
1537
+ /**
1538
+ * Trigger if page contains a table
1539
+ */
1540
+ table_in_page?: boolean | null;
1541
+
1542
+ /**
1543
+ * Trigger if page text/markdown contains this string
1544
+ */
1545
+ text_in_page?: string | null;
1546
+
1547
+ /**
1548
+ * How to combine multiple trigger conditions: 'and' (all conditions must match,
1549
+ * this is the default) or 'or' (any single condition can trigger)
1550
+ */
1551
+ trigger_mode?: string | null;
1552
+ }
1553
+
1554
+ export namespace AutoModeConfiguration {
1555
+ /**
1556
+ * Parsing configuration to apply when trigger conditions are met
1557
+ */
1558
+ export interface ParsingConf {
1559
+ /**
1560
+ * Whether to use adaptive long table handling
1561
+ */
1562
+ adaptive_long_table?: boolean | null;
1563
+
1564
+ /**
1565
+ * Whether to use aggressive table extraction
1566
+ */
1567
+ aggressive_table_extraction?: boolean | null;
1568
+
1569
+ /**
1570
+ * Crop box options for auto mode parsing configuration.
1571
+ */
1572
+ crop_box?: ParsingConf.CropBox | null;
1573
+
1574
+ /**
1575
+ * Custom AI instructions for matched pages. Overrides the base custom_prompt
1576
+ */
1577
+ custom_prompt?: string | null;
1578
+
1579
+ /**
1580
+ * Whether to extract layout information
1581
+ */
1582
+ extract_layout?: boolean | null;
1583
+
1584
+ /**
1585
+ * Whether to use high resolution OCR
1586
+ */
1587
+ high_res_ocr?: boolean | null;
1588
+
1589
+ /**
1590
+ * Ignore options for auto mode parsing configuration.
1591
+ */
1592
+ ignore?: ParsingConf.Ignore | null;
1593
+
1594
+ /**
1595
+ * Primary language of the document
1596
+ */
1597
+ language?: string | null;
1598
+
1599
+ /**
1600
+ * Whether to use outlined table extraction
1601
+ */
1602
+ outlined_table_extraction?: boolean | null;
1603
+
1604
+ /**
1605
+ * Presentation-specific options for auto mode parsing configuration.
1606
+ */
1607
+ presentation?: ParsingConf.Presentation | null;
1608
+
1609
+ /**
1610
+ * Spatial text options for auto mode parsing configuration.
1611
+ */
1612
+ spatial_text?: ParsingConf.SpatialText | null;
1613
+
1614
+ /**
1615
+ * Enable specialized chart parsing with the specified mode
1616
+ */
1617
+ specialized_chart_parsing?: 'agentic_plus' | 'agentic' | 'efficient' | null;
1618
+
1619
+ /**
1620
+ * Override the parsing tier for matched pages. Must be paired with version
1621
+ */
1622
+ tier?: 'fast' | 'cost_effective' | 'agentic' | 'agentic_plus' | null;
1623
+
1624
+ /**
1625
+ * Tier version when overriding tier. Required when tier is specified
1626
+ */
1627
+ version?:
1628
+ | '2025-12-11'
1629
+ | '2025-12-18'
1630
+ | '2025-12-31'
1631
+ | '2026-01-08'
1632
+ | '2026-01-09'
1633
+ | '2026-01-16'
1634
+ | '2026-01-21'
1635
+ | '2026-01-22'
1636
+ | '2026-01-24'
1637
+ | '2026-01-29'
1638
+ | '2026-01-30'
1639
+ | '2026-02-03'
1640
+ | '2026-02-18'
1641
+ | '2026-02-20'
1642
+ | '2026-02-24'
1643
+ | '2026-02-26'
1644
+ | '2026-03-02'
1645
+ | '2026-03-03'
1646
+ | '2026-03-04'
1647
+ | '2026-03-05'
1648
+ | '2026-03-09'
1649
+ | '2026-03-10'
1650
+ | '2026-03-11'
1651
+ | '2026-03-12'
1652
+ | '2026-03-17'
1653
+ | '2026-03-19'
1654
+ | '2026-03-20'
1655
+ | '2026-03-22'
1656
+ | '2026-03-23'
1657
+ | '2026-03-24'
1658
+ | '2026-03-25'
1659
+ | '2026-03-26'
1660
+ | '2026-03-27'
1661
+ | 'latest'
1662
+ | (string & {})
1663
+ | null;
1664
+ }
1665
+
1666
+ export namespace ParsingConf {
1667
+ /**
1668
+ * Crop box options for auto mode parsing configuration.
1669
+ */
1670
+ export interface CropBox {
1671
+ /**
1672
+ * Bottom boundary of crop box as ratio (0-1)
1673
+ */
1674
+ bottom?: number | null;
1675
+
1676
+ /**
1677
+ * Left boundary of crop box as ratio (0-1)
1678
+ */
1679
+ left?: number | null;
1680
+
1681
+ /**
1682
+ * Right boundary of crop box as ratio (0-1)
1683
+ */
1684
+ right?: number | null;
1685
+
1686
+ /**
1687
+ * Top boundary of crop box as ratio (0-1)
1688
+ */
1689
+ top?: number | null;
1690
+ }
1691
+
1692
+ /**
1693
+ * Ignore options for auto mode parsing configuration.
1694
+ */
1695
+ export interface Ignore {
1696
+ /**
1697
+ * Whether to ignore diagonal text in the document
1698
+ */
1699
+ ignore_diagonal_text?: boolean | null;
1700
+
1701
+ /**
1702
+ * Whether to ignore hidden text in the document
1703
+ */
1704
+ ignore_hidden_text?: boolean | null;
1705
+ }
1706
+
1707
+ /**
1708
+ * Presentation-specific options for auto mode parsing configuration.
1709
+ */
1710
+ export interface Presentation {
1711
+ /**
1712
+ * Extract out of bounds content in presentation slides
1713
+ */
1714
+ out_of_bounds_content?: boolean | null;
1715
+
1716
+ /**
1717
+ * Skip extraction of embedded data for charts in presentation slides
1718
+ */
1719
+ skip_embedded_data?: boolean | null;
1720
+ }
1721
+
1722
+ /**
1723
+ * Spatial text options for auto mode parsing configuration.
1724
+ */
1725
+ export interface SpatialText {
1726
+ /**
1727
+ * Keep column structure intact without unrolling
1728
+ */
1729
+ do_not_unroll_columns?: boolean | null;
1730
+
1731
+ /**
1732
+ * Preserve text alignment across page boundaries
1733
+ */
1734
+ preserve_layout_alignment_across_pages?: boolean | null;
1735
+
1736
+ /**
1737
+ * Include very small text in spatial output
1738
+ */
1739
+ preserve_very_small_text?: boolean | null;
1740
+ }
1741
+ }
1742
+ }
1743
+
1744
+ /**
1745
+ * Cost optimizer configuration for reducing parsing costs on simpler pages.
1746
+ *
1747
+ * When enabled, the parser analyzes each page and routes simpler pages to faster,
1748
+ * cheaper processing while preserving quality for complex pages. Only works with
1749
+ * 'agentic' or 'agentic_plus' tiers.
1750
+ */
1751
+ export interface CostOptimizer {
1752
+ /**
1753
+ * Enable cost-optimized parsing. Routes simpler pages to faster processing while
1754
+ * complex pages use full AI analysis. May reduce speed on some documents.
1755
+ * IMPORTANT: Only available with 'agentic' or 'agentic_plus' tiers
1756
+ */
1757
+ enable?: boolean | null;
1758
+ }
1759
+
1760
+ /**
1761
+ * Options for ignoring specific text types (diagonal, hidden, text in images)
1762
+ */
1763
+ export interface Ignore {
1764
+ /**
1765
+ * Skip text rotated at an angle (not horizontal/vertical). Useful for ignoring
1766
+ * watermarks or decorative angled text
1767
+ */
1768
+ ignore_diagonal_text?: boolean | null;
1769
+
1770
+ /**
1771
+ * Skip text marked as hidden in the document structure. Some PDFs contain
1772
+ * invisible text layers used for accessibility or search indexing
1773
+ */
1774
+ ignore_hidden_text?: boolean | null;
1775
+
1776
+ /**
1777
+ * Skip OCR text extraction from embedded images. Use when images contain
1778
+ * irrelevant text (watermarks, logos) that shouldn't be in the output
1779
+ */
1780
+ ignore_text_in_image?: boolean | null;
1781
+ }
1782
+
1783
+ /**
1784
+ * OCR configuration including language detection settings
1785
+ */
1786
+ export interface OcrParameters {
1787
+ /**
1788
+ * Languages to use for OCR text recognition. Specify multiple languages if
1789
+ * document contains mixed-language content. Order matters - put primary language
1790
+ * first. Example: ['en', 'es'] for English with Spanish
1791
+ */
1792
+ languages?: Array<ParsingAPI.ParsingLanguages> | null;
1793
+ }
1794
+ }
1795
+
1796
+ /**
1797
+ * Webhook configuration for receiving parsing job notifications.
1798
+ *
1799
+ * Webhooks are called when specified events occur during job processing. Configure
1800
+ * multiple webhook configurations to send to different endpoints.
1801
+ */
1802
+ export interface WebhookConfiguration {
1803
+ /**
1804
+ * Events that trigger this webhook. Options: 'parse.success' (job completed),
1805
+ * 'parse.failure' (job failed), 'parse.partial' (some pages failed). If not
1806
+ * specified, webhook fires for all events
1807
+ */
1808
+ webhook_events?: Array<string> | null;
1809
+
1810
+ /**
1811
+ * Custom HTTP headers to include in webhook requests. Use for authentication
1812
+ * tokens or custom routing. Example: {'Authorization': 'Bearer xyz'}
1813
+ */
1814
+ webhook_headers?: { [key: string]: unknown } | null;
1815
+
1816
+ /**
1817
+ * HTTPS URL to receive webhook POST requests. Must be publicly accessible
1818
+ */
1819
+ webhook_url?: string | null;
1820
+ }
1821
+ }
1822
+
1823
+ /**
1824
+ * Catch-all for configurations without a dedicated typed schema.
1825
+ *
1826
+ * Accepts arbitrary JSON fields alongside `product_type`.
1827
+ */
1828
+ export interface UntypedParameters {
1829
+ /**
1830
+ * Product type.
1831
+ */
1832
+ product_type: 'unknown';
1833
+
1834
+ [k: string]: unknown;
1835
+ }
1836
+ }
1837
+
1838
+ export interface ExtractCreateParams {
1839
+ /**
1840
+ * Body param: File ID or Parse Job ID to extract from
1841
+ */
1842
+ document_input_value: string;
1843
+
1844
+ /**
1845
+ * Query param
1846
+ */
1847
+ organization_id?: string | null;
1848
+
1849
+ /**
1850
+ * Query param
1851
+ */
1852
+ project_id?: string | null;
1853
+
1854
+ /**
1855
+ * Body param: Extract configuration combining parse and extract settings.
1856
+ */
1857
+ configuration?: ExtractConfiguration | null;
1858
+
1859
+ /**
1860
+ * Body param: Saved extract configuration ID (mutually exclusive with
1861
+ * configuration)
1862
+ */
1863
+ configuration_id?: string | null;
1864
+
1865
+ /**
1866
+ * Body param: Outbound webhook endpoints to notify on job status changes
1867
+ */
1868
+ webhook_configurations?: Array<ExtractCreateParams.WebhookConfiguration> | null;
1869
+ }
1870
+
1871
+ export namespace ExtractCreateParams {
1872
+ /**
1873
+ * Configuration for a single outbound webhook endpoint.
1874
+ */
1875
+ export interface WebhookConfiguration {
1876
+ /**
1877
+ * Events to subscribe to (e.g. 'parse.success', 'extract.error'). If null, all
1878
+ * events are delivered.
1879
+ */
1880
+ webhook_events?: Array<
1881
+ | 'extract.pending'
1882
+ | 'extract.success'
1883
+ | 'extract.error'
1884
+ | 'extract.partial_success'
1885
+ | 'extract.cancelled'
1886
+ | 'parse.pending'
1887
+ | 'parse.running'
1888
+ | 'parse.success'
1889
+ | 'parse.error'
1890
+ | 'parse.partial_success'
1891
+ | 'parse.cancelled'
1892
+ | 'classify.pending'
1893
+ | 'classify.success'
1894
+ | 'classify.error'
1895
+ | 'classify.partial_success'
1896
+ | 'classify.cancelled'
1897
+ | 'unmapped_event'
1898
+ > | null;
1899
+
1900
+ /**
1901
+ * Custom HTTP headers sent with each webhook request (e.g. auth tokens)
1902
+ */
1903
+ webhook_headers?: { [key: string]: string } | null;
1904
+
1905
+ /**
1906
+ * Response format sent to the webhook: 'string' (default) or 'json'
1907
+ */
1908
+ webhook_output_format?: string | null;
1909
+
1910
+ /**
1911
+ * URL to receive webhook POST notifications
1912
+ */
1913
+ webhook_url?: string | null;
1914
+ }
1915
+ }
1916
+
1917
+ export interface ExtractListParams extends PaginatedCursorParams {
1918
+ /**
1919
+ * Filter by configuration ID
1920
+ */
1921
+ configuration_id?: string | null;
1922
+
1923
+ /**
1924
+ * Include jobs created at or after this timestamp (inclusive)
1925
+ */
1926
+ created_at_on_or_after?: string | null;
1927
+
1928
+ /**
1929
+ * Include jobs created at or before this timestamp (inclusive)
1930
+ */
1931
+ created_at_on_or_before?: string | null;
1932
+
1933
+ /**
1934
+ * Filter by document input type (file_id or parse_job_id)
1935
+ */
1936
+ document_input_type?: string | null;
1937
+
1938
+ /**
1939
+ * Filter by document input value
1940
+ */
1941
+ document_input_value?: string | null;
1942
+
1943
+ /**
1944
+ * Additional fields to include: configuration, extract_metadata
1945
+ */
1946
+ expand?: Array<string>;
1947
+
1948
+ /**
1949
+ * Filter by specific job IDs
1950
+ */
1951
+ job_ids?: Array<string> | null;
1952
+
1953
+ organization_id?: string | null;
1954
+
1955
+ project_id?: string | null;
1956
+
1957
+ /**
1958
+ * Filter by status
1959
+ */
1960
+ status?: 'PENDING' | 'THROTTLED' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | null;
1961
+ }
1962
+
1963
+ export interface ExtractDeleteParams {
1964
+ organization_id?: string | null;
1965
+
1966
+ project_id?: string | null;
1967
+ }
1968
+
1969
+ export interface ExtractGenerateSchemaParams {
1970
+ /**
1971
+ * Query param
1972
+ */
1973
+ organization_id?: string | null;
1974
+
1975
+ /**
1976
+ * Query param
1977
+ */
1978
+ project_id?: string | null;
1979
+
1980
+ /**
1981
+ * Body param: Optional schema to validate, refine, or extend
1982
+ */
1983
+ data_schema?: {
1984
+ [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null;
1985
+ } | null;
1986
+
1987
+ /**
1988
+ * Body param: Optional file ID to analyze for schema generation
1989
+ */
1990
+ file_id?: string | null;
1991
+
1992
+ /**
1993
+ * Body param: Name for the generated configuration (auto-generated if omitted)
1994
+ */
1995
+ name?: string | null;
1996
+
1997
+ /**
1998
+ * Body param: Natural language description of the data structure to extract
1999
+ */
2000
+ prompt?: string | null;
2001
+ }
2002
+
2003
+ export interface ExtractGetParams {
2004
+ /**
2005
+ * Additional fields to include: configuration, extract_metadata
2006
+ */
2007
+ expand?: Array<string>;
2008
+
2009
+ organization_id?: string | null;
2010
+
2011
+ project_id?: string | null;
2012
+ }
2013
+
2014
+ export interface ExtractValidateSchemaParams {
2015
+ /**
2016
+ * JSON Schema to validate for use with extract jobs
2017
+ */
2018
+ data_schema: {
2019
+ [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null;
2020
+ };
2021
+ }
2022
+
2023
+ export declare namespace Extract {
2024
+ export {
2025
+ type ExtractConfiguration as ExtractConfiguration,
2026
+ type ExtractJobMetadata as ExtractJobMetadata,
2027
+ type ExtractJobUsage as ExtractJobUsage,
2028
+ type ExtractV2Job as ExtractV2Job,
2029
+ type ExtractV2JobCreate as ExtractV2JobCreate,
2030
+ type ExtractV2JobQueryResponse as ExtractV2JobQueryResponse,
2031
+ type ExtractV2SchemaGenerateRequest as ExtractV2SchemaGenerateRequest,
2032
+ type ExtractV2SchemaValidateRequest as ExtractV2SchemaValidateRequest,
2033
+ type ExtractV2SchemaValidateResponse as ExtractV2SchemaValidateResponse,
2034
+ type ExtractedFieldMetadata as ExtractedFieldMetadata,
2035
+ type ExtractDeleteResponse as ExtractDeleteResponse,
2036
+ type ExtractGenerateSchemaResponse as ExtractGenerateSchemaResponse,
2037
+ type ExtractV2JobsPaginatedCursor as ExtractV2JobsPaginatedCursor,
2038
+ type ExtractCreateParams as ExtractCreateParams,
2039
+ type ExtractListParams as ExtractListParams,
2040
+ type ExtractDeleteParams as ExtractDeleteParams,
2041
+ type ExtractGenerateSchemaParams as ExtractGenerateSchemaParams,
2042
+ type ExtractGetParams as ExtractGetParams,
2043
+ type ExtractValidateSchemaParams as ExtractValidateSchemaParams,
2044
+ };
2045
+ }