-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenapi.yaml
2548 lines (2428 loc) · 96.8 KB
/
openapi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.0.0
info:
title: AI Hub API
version: "0.1"
description: The AI Hub REST API. See https://docs.instabase.com/api-sdk/ for more details.
termsOfService: https://www.instabase.com/terms-of-service/
contact:
name: Instabase Support
url: https://help.instabase.com/
license:
name: MIT
url: https://github.com/instabase/aihub-python/blob/master/LICENSE
servers:
- url: https://aihub.instabase.com/api
security:
- bearerAuth: []
paths:
/v2/batches:
post:
operationId: createBatch
x-fern-audiences:
- public
tags:
- batches
summary: Create batch
description: |
Create a new batch.
<Note>[Upload files to the batch](/api-sdk/api-reference/batches/add-file-to-batch) in a separate request.</Note>
parameters:
- $ref: '#/components/parameters/ib_context'
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
name:
type: string
description: Name of the batch. Maximum length is 255 characters.
workspace:
type: string
description: |
The name of the workspace in which to add the batch; the batch is created in the default drive of the workspace. If not specified, the default location for organization members is the default drive of your personal workspace. For community users, the default location is your personal workspace's Instabase Drive.
When making this call from a service account, you must specify a workspace.
<Info>For organization members, if the default drive changes but is still connected, you can still use the batch as input for running an app. However, you can't upload any additional files to the batch. If the default drive is disconnected, you can't use batches stored on that drive as input for any app run.</Info>
required:
- name
responses:
'200':
description: Batch created successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/batch'
default:
content:
application/json:
schema:
$ref: '#/components/schemas/error'
description: Error response.
x-fern-examples:
- code-samples:
- sdk: curl
code: |
curl "${API_ROOT}/v2/batches" \
-H "Authorization: Bearer ${API_TOKEN}" \
-H "IB-Context: ${IB_CONTEXT}"\
-H "Content-Type: application/json" \
-d '{"name": "test"}'
- sdk: python
code: |
# AI Hub Python SDK example
from aihub import AIHub
client = AIHub(api_root="<API-ROOT>",
api_key="<API-TOKEN>",
ib_context="<IB-CONTEXT>")
batch = client.batches.create(name='test')
get:
operationId: listBatches
x-fern-audiences:
- public
tags:
- batches
summary: List batches
description: Return a list of batches. Use query parameters to filter results.
parameters:
- in: query
name: workspace
schema:
type: string
description: Filter to batches in the specified workspace.
- in: query
name: username
schema:
type: string
description: Filter to batches created by the specified username (user ID).
- in: query
name: limit
schema:
type: integer
description: If paginating results, specify how many batches to return.
- in: query
name: file_offset
schema:
type: integer
description: If paginating results, specify the offset of the returned list.
- $ref: '#/components/parameters/ib_context'
responses:
'200':
description: Request successful.
content:
application/json:
schema:
type: object
properties:
batches:
type: array
description: List of batches. See response schema for each batch object.
items:
$ref: '#/components/schemas/batchInfo'
x-fern-examples:
- code-samples:
- sdk: curl
code: |
curl "${API_ROOT}/v2/batches" \
-H "Authorization: Bearer ${API_TOKEN}" \
-H "IB-Context: ${IB_CONTEXT}"\
-G \
--data-urlencode "workspace=my-workspace" \
--data-urlencode "limit=100"
- sdk: python
code: |
# AI Hub Python SDK example
from aihub import AIHub
client = AIHub(api_root="<API-ROOT>",
api_key="<API-TOKEN>",
ib_context="<IB-CONTEXT>")
batches = client.batches.list(workspace="my-workspace",
limit=100)
/v2/batches/{batch_id}:
get:
operationId: getBatch
x-fern-audiences:
- public
tags:
- batches
summary: Get batch information
description: Retrieve information about a batch.
parameters:
- $ref: '#/components/parameters/batch_id'
- $ref: '#/components/parameters/ib_context'
responses:
'200':
description: Batch successfully retrieved.
content:
application/json:
schema:
$ref: '#/components/schemas/batchInfo'
'404':
description: Batch does not exist, or denied access.
x-fern-examples:
- code-samples:
- sdk: curl
code: |
curl "${API_ROOT}/v2/batches/<BATCH-ID>" \
-H "Authorization: Bearer ${API_TOKEN}"\
-H "IB-Context: ${IB_CONTEXT}"
- sdk: python
code: |
# AI Hub Python SDK example
from aihub import AIHub
client = AIHub(api_root="<API-ROOT>",
api_key="<API-TOKEN>",
ib_context="<IB-CONTEXT>")
batch = client.batches.get("<BATCH-ID>")
delete:
operationId: deleteBatch
x-fern-audiences:
- public
tags:
- batches
summary: Delete batch
description: Delete a batch and all its files. This is an asynchronous operation that must be [checked for completion.](/api-sdk/api-reference/batches/poll-batches-job)
parameters:
- $ref: '#/components/parameters/batch_id'
- $ref: '#/components/parameters/ib_context'
responses:
'202':
description: Batch deletion request accepted. [Poll the job ID](/api-sdk/api-reference/batches/poll-batches-job) to check completion status.
content:
application/json:
schema:
$ref: '#/components/schemas/batchDeletionJobResponse'
'404':
description: Batch does not exist.
x-fern-examples:
- code-samples:
- sdk: curl
code: |
curl -X DELETE "${API_ROOT}/v2/batches/<BATCH-ID>" \
-H "Authorization: Bearer ${API_TOKEN}"\
-H "IB-Context: ${IB_CONTEXT}"
- sdk: python
code: |
# AI Hub Python SDK example
from aihub import AIHub
client = AIHub(api_root="<API-ROOT>",
api_key="<API-TOKEN>",
ib_context="<IB-CONTEXT>")
resp = client.batches.delete("<BATCH-ID>")
job_id = resp.job_id
# Poll for job completion
while True:
job_status = client.jobs.status(job_id)
if job_status.state == 'COMPLETE':
break
time.sleep(5)
/v2/batches/{batch_id}/files/{filename}:
put:
operationId: addFileToBatch
x-fern-audiences:
- public
tags:
- batches
summary: Upload file to batch
description: |
Upload a file to a batch or update the contents of a previously uploaded file in a batch.
<Info>Files can be uploaded one at a time and the suggested max size for each file is 10 MB. For larger files, see [Multipart file upload.](/api-sdk/multipart-upload/)</Info>
parameters:
- $ref: '#/components/parameters/batch_id'
- name: filename
in: path
required: true
description: A user-defined name for the file. Include the file extension.
schema:
type: string
- $ref: '#/components/parameters/ib_context'
requestBody:
required: true
content:
application/octet-stream:
schema:
description: The raw contents of the file to upload. See the example request, being sure to define the `<LOCAL_FILEPATH>` with the full path to the file in the machine running the script.
type: string
format: binary
responses:
'204':
description: File uploaded successfully.
'404':
description: Batch with ID <BATCH-ID> does not exist.
default:
content:
application/json:
schema:
$ref: '#/components/schemas/error'
description: Error response.
x-fern-examples:
- code-samples:
- sdk: curl
code: |
curl -X PUT "${API_ROOT}/v2/batches/<BATCH-ID>/files/<FILENAME>" \
-H "Authorization: Bearer ${API_TOKEN}" \
-H "IB-Context: ${IB_CONTEXT}" \
-H "Content-Type: application/octet-stream" \
--upload-file '<LOCAL_FILEPATH>' # Full path to the file in the machine that's making the request
- sdk: python
code: |
# AI Hub Python SDK example
from aihub import AIHub
client = AIHub(api_root="<API-ROOT>",
api_key="<API-TOKEN>",
ib_context="<IB-CONTEXT>")
client.batches.add_file(batch_id="<BATCH-ID>",
file_name="test.pdf",
file=open("test.pdf", "rb"))
delete:
operationId: deleteFileFromBatch
x-fern-audiences:
- public
tags:
- batches
summary: Delete file from batch
description: Delete a file from a batch.
parameters:
- $ref: '#/components/parameters/batch_id'
- name: filename
in: path
required: true
description: The name of the file.
schema:
type: string
- $ref: '#/components/parameters/ib_context'
responses:
'202':
description: File deletion request accepted. Poll the deletion job for completion status.
'404':
description: Batch does not exist.
x-fern-examples:
- code-samples:
- sdk: curl
code: |
curl -X DELETE "${API_ROOT}/v2/batches/<BATCH-ID>/files/<FILENAME>" \
-H "Authorization: Bearer ${API_TOKEN}"\
-H "IB-Context: ${IB_CONTEXT}"
- sdk: python
code: |
# AI Hub Python SDK example
from aihub import AIHub
client = AIHub(api_root="<API-ROOT>",
api_key="<API-TOKEN>",
ib_context="<IB-CONTEXT>")
resp = client.batches.delete_file("<BATCH-ID>",
"<FILENAME>")
/v2/batches/jobs/{job_id}:
get:
operationId: pollBatchesJob
x-fern-audiences:
- public
tags:
- batches
summary: Poll batches job
description: Poll the asynchronous job created when deleting a batch or deleting a file from a batch.
parameters:
- name: job_id
in: path
required: true
schema:
type: string
description: The job ID returned by a [Delete batch](/api-sdk/api-reference/batches/delete-batch) request or the `Location` header value returned by a [Delete file from a batch](/api-sdk/api-reference/batches/delete-file-from-batch) request.
- $ref: '#/components/parameters/ib_context'
responses:
'200':
description: Request successful
content:
application/json:
schema:
$ref: '#/components/schemas/jobStatusResponse'
x-fern-examples:
- code-samples:
- sdk: curl
code: |
curl "${API_ROOT}/v2/batches/jobs/<JOB-ID>" \
-H "Authorization: Bearer ${API_TOKEN}"\
-H "IB-Context: ${IB_CONTEXT}"
- sdk: python
code: |
# AI Hub Python SDK example
from aihub import AIHub
client = AIHub(api_root="<API-ROOT>",
api_key="<API-TOKEN>",
ib_context="<IB-CONTEXT>")
resp = client.batches.poll_job("<JOB-ID>")
/v2/apps/runs:
post:
operationId: runApp
x-fern-audiences:
- public
tags:
- runs
summary: Run app
description: |
Run an app by its name or app ID. The input for the run can be a batch ID or an input file path.
<Tip>
<span class="badge">Commercial & Enterprise</span>
Running an app via a deployment is generally preferred over running an app directly.
Deployments offer additional features including upstream and downstream integrations, deployment metrics, human review workflows, and secret and configuration management.
Learn more about [deployments](/apps/run-and-deploy#creating-deployments) to decide if you'd rather use the [Run deployment](/api-sdk/api-reference/runs/run-deployment) API operation.
</Tip>
<Note>Any specified input or output is validated against the context set by the `IB-Context` header. For example, if the context is set to your community account, but the batch ID used as input for the run is stored in your organization, the call fails.</Note>
parameters:
- $ref: '#/components/parameters/ib_context'
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
app_name:
type: string
description: Required unless using `app_id`. The name of the AI Hub app to run.
app_id:
type: string
description: |
Required unless using `app_name`. The app ID of the AI Hub app to run.
<Tip>You can find an app ID in the app URL, such as http<span>s://</span>aihub.instabase.com/hub/apps/**528c36e8-ac5b-490d-a41b-7eec9c404b87**.</Tip>
owner:
type: string
description: |
The account that generated the app. If not specified, defaults to your AI Hub username.
For custom AI Hub apps belonging to you, accept the default. For public AI Hub apps published by Instabase, specify `instabase`.
batch_id:
type: integer
description: Required unless using `input_dir`. The batch ID of a batch created with the [Batches endpoint.](/api-sdk/api-reference/batches/create-batch/) All files uploaded to the batch are used as input for the run.
input_dir:
type: string
description: Required unless using `batch_id`. The path of the input folder in a connected drive or Instabase Drive. See [Specifying file paths.](/api-sdk/api-reference/run-reference#specifying-file-paths)
version:
type: string
description: Version of the app to use. If not specified, defaults to the latest production version.
output_workspace:
type: string
description: |
The workspace in which to run the app. The output is saved to the default drive of the specified workspace. If not defined, the default is:
- **Community accounts**: Runs in and saves to the personal workspace's Instabase Drive (`<USER-ID>/my-repo/Instabase Drive`).
- **Organization accounts**: Runs in and saves to the organization's default drive (`<ORGANIZATION-ID>/<USER-ID>/<default-drive>`).
<Note>If this parameter is not specified, the results are sent to the user's personal workspace. This can cause visibility problems in shared workspaces.</Note>
When making this call from a service account, you must specify a value for either `output_workspace` or `output_dir`.
output_dir:
type: string
description: Defines a specific location for the output to be saved in a connected drive or Instabase Drive. If defined, overrides the `output_workspace` value. See [Specifying file paths.](/api-sdk/api-reference/run-reference#specifying-file-paths)
settings:
type: object
description: JSON object containing settings for the app run.
properties:
runtime_config:
type: object
description: A dictionary containing the runtime configuration for the app run, for use in validation functions and to generate retrievable PDFs of processed documents. See [runtime config](/api-sdk/api-reference/run-reference#runtime-configs) for details.
additionalProperties: true
webhook_config:
type: object
description: Configuration for the webhook URL called on app run completion. See [webhook parameters](/api-sdk/api-reference/run-reference#webhook-parameters) for details.
properties:
url:
type: string
description: The webhook URL to which an HTTP request is sent when the run is completed.
headers:
type: object
description: Configure the headers that are sent alongside the HTTP request. The format is a dictionary of key-value pairs.
additionalProperties:
type: string
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/run'
description: Run started successfully.
default:
content:
application/json:
schema:
$ref: '#/components/schemas/error'
description: Error response.
x-fern-examples:
- code-samples:
- sdk: curl
name: Simple request
code: |
curl "${API_ROOT}/v2/apps/runs" \
-H "Authorization: Bearer ${API_TOKEN}" \
-H "IB-Context: ${IB_CONTEXT}"\
-H "Content-Type: application/json" \
-d '{
"batch_id": "<BATCH-ID>",
"app_name": "<APP-NAME>"
}'
- sdk: python
name: Simple request
code: |
# AI Hub Python SDK example
from aihub import AIHub
client = AIHub(api_root="<API-ROOT>",
api_key="<API-TOKEN>",
ib_context="<IB-CONTEXT>")
result = client.apps.runs.create(app_name='<APP-NAME>',
batch_id='<BATCH-ID>')
- code-samples:
- sdk: curl
name: Post-processed-pdf generation enabled
code: |
curl "${API_ROOT}/v2/apps/runs" \
-H "Authorization: Bearer ${API_TOKEN}" \
-H "IB-Context: ${IB_CONTEXT}"\
-H "Content-Type: application/json" \
-d '{
"batch_id": "<BATCH-ID>",
"app_name": "<APP-NAME>",
"settings": {
"runtime_config": {
"generate_post_process_pdf": true
}
}
}'
- sdk: python
name: Post-processed-pdf generation enabled
code: |
# AI Hub Python SDK example
from aihub import AIHub
client = AIHub(api_root="<API-ROOT>",
api_key="<API-TOKEN>",
ib_context="<IB-CONTEXT>")
result = client.apps.runs.create(app_name='<APP-NAME>',
batch_id='<BATCH-ID>',
settings={"runtime_config":{"generate_post_process_pdf": true}})
get:
operationId: listRuns
x-fern-audiences:
- public
tags:
- runs
summary: List runs
description: Return a list of runs. Use query parameters to filter results.
parameters:
- $ref: '#/components/parameters/ib_context'
- in: query
name: app_id
schema:
type: string
description: Filter runs by app ID.
- in: query
name: app_name
schema:
type: string
description: Filter runs by app name.
- in: query
name: deployment_id
schema:
type: string
description: Filter runs by app deployment ID.
- in: query
name: username
schema:
type: string
description: Filter runs initiated by the specified user (username).
- in: query
name: run_id
schema:
type: string
description: Filter specific run by run ID.
- in: query
name: status
schema:
type: array
items:
type: string
description: Filter jobs by status, such as COMPLETE, RUNNING, or FAILED.
- in: query
name: output_repo
schema:
type: array
items:
type: string
description: Filter runs by the output repo.
- in: query
name: from_timestamp
schema:
type: integer
description: Filter runs starting from this timestamp. Defaults to one week before the current time.
- in: query
name: to_timestamp
schema:
type: integer
description: Filter runs up to this timestamp. Defaults to the current time.
- in: query
name: limit
schema:
type: integer
description: Number of results to return.
- in: query
name: offset
schema:
type: integer
description: Offset of the first result to return.
- in: query
name: sort_by
schema:
type: string
enum:
- start_timestamp
- status
description: Field to sort results by.
- in: query
name: order
schema:
type: string
enum:
- ASCENDING
- DESCENDING
description: Order of sorting, such as ASCENDING or DESCENDING.
responses:
'200':
description: A list of all runs.
content:
application/json:
schema:
type: object
properties:
runs:
type: array
items:
$ref: '#/components/schemas/run'
default:
description: Error response.
content:
application/json:
schema:
$ref: '#/components/schemas/error'
x-fern-examples:
- code-samples:
- sdk: curl
code: |
curl "${API_ROOT}/v2/apps/runs" \
-H "Authorization: Bearer ${API_TOKEN}"`
-H "IB-Context: ${IB_CONTEXT}"
- sdk: python
code: |
# AI Hub Python SDK example
from aihub import AIHub
client = AIHub(api_root="<API-ROOT>",
api_key="<API-TOKEN>",
ib_context="<IB-CONTEXT>")
runs = client.apps.runs.list()
/v2/apps/deployments/{deployment-id}/runs:
post:
operationId: runDeployment
x-fern-audiences:
- public
tags:
- runs
summary: Run deployment
description: |
<span class="badge">Commercial & Enterprise</span>
Run an AI Hub deployment by its deployment ID. The input for the run is specified using a batch ID or file path.
<Note>Any specified input or output is validated against the context set by the `IB-Context` header. For example, if the context is set to your community account, but the batch ID used as input for the run is stored in your organization, the call fails.</Note>
parameters:
- $ref: '#/components/parameters/ib_context'
- in: path
name: deployment-id
schema:
type: string
default: false
required: true
description: |
The deployment ID.
<Tip>You can find the deployment ID by opening the deployment in AI Hub and looking at the site URL, such as https<span>://</span>aihub.instabase.com/deployments/**01902d6f-bb35-74cb-bd27-c09b38bbf20a**/runs.</Tip>
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
batch_id:
type: integer
description: Required unless using `input_dir` or `manual_upstream_integration`. The batch ID of a batch created with the [Batches endpoint](/api-sdk/api-reference/batches/create-batch/). All files uploaded to the batch are used as input for the run.
input_dir:
type: integer
description: Required unless using `batch_id` or `manual_upstream_integration`. The path of the input folder in a connected drive or Instabase Drive. See [Specifying file paths](/api-sdk/api-reference/run-reference#specifying-file-paths).
manual_upstream_integration:
type: boolean
description: Use the deployment's upstream integration as a source rather than a `batch_id` or `input_dir`. Requires an upstream integration to be configured for the deployment.
from_timestamp:
type: number
description: Required if `manual_upstream_integration` is true and the upstream integration is a mailbox integration. Specifies the earliest date in Unix time milliseconds from which to pull emails.
to_timestamp:
type: number
description: Required if `manual_upstream_integration` is true and the upstream integration is a mailbox integration. Specifies the latest date in Unix time milliseconds from which to pull emails.
version:
type: string
description: Version of the app to use. If not specified, defaults to the latest production version.
output_workspace:
type: string
description: |
The workspace in which to run the app. The output is saved to the default drive of the specified workspace. If not defined, the default is:
- **Community accounts**: Runs in and saves to the personal workspace's Instabase Drive (`<USER-ID>/my-repo/Instabase Drive`).
- **Organization accounts**: Runs in and saves to the organization's default drive (`<ORGANIZATION-ID>/<USER-ID>/<default-drive>`).
When making this call from a service account, you must specify a value for either `output_workspace` or `output_dir`.
output_dir:
type: string
description: Defines a specific location for the output to be saved in a connected drive or Instabase Drive. If defined, overrides the `output_workspace` value. See [Specifying file paths](/api-sdk/api-reference/run-reference#specifying-file-paths).
settings:
type: object
description: JSON object containing settings for the app run.
properties:
runtime_config:
type: object
description: A dictionary containing the runtime configuration for the app run, for use in validation functions. See [runtime config](/api-sdk/api-reference/run-reference#runtime-configs) for details.
additionalProperties: true
webhook_config:
type: object
description: Configuration for the webhook URL called on app run completion. See [Webhook parameters](/api-sdk/api-reference/run-reference#webhook-parameters).
properties:
url:
type: string
description: The webhook URL to which an HTTP request is sent when the run is completed.
headers:
type: object
description: Configure the headers that are sent alongside the HTTP request. The format is a dictionary of key-value pairs.
additionalProperties:
type: string
responses:
'202':
content:
application/json:
schema:
$ref: '#/components/schemas/run'
description: Successfully initiated an asynchronous operation to run the deployment.
default:
content:
application/json:
schema:
$ref: '#/components/schemas/error'
description: Error response.
x-fern-examples:
- code-samples:
- sdk: curl
code: |
curl "${API_ROOT}/v2/apps/deployments/<DEPLOYMENT-ID>/runs" \
-H "Authorization: Bearer ${API_TOKEN}" \
-H "IB-Context: ${IB_CONTEXT}"\
-H "Content-Type: application/json" \
-d '{
"batch_id": "<BATCH-ID>",
}'
/v2/apps/runs/{run_id}:
get:
operationId: getRunStatus
x-fern-audiences:
- public
tags:
- runs
summary: Get run status
description: Get the status of a run.
parameters:
- $ref: '#/components/parameters/run_id'
- $ref: '#/components/parameters/ib_context'
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/run'
description: Successful response.
default:
content:
application/json:
schema:
$ref: '#/components/schemas/error'
description: Error response.
x-fern-examples:
- code-samples:
- sdk: curl
code: |
curl "${API_ROOT}/v2/apps/runs/<RUN-ID>" \
-H "Authorization: Bearer ${API_TOKEN}"\
-H "IB-Context: ${IB_CONTEXT}"
- sdk: python
code: |
# AI Hub Python SDK example
from aihub import AIHub
client = AIHub(api_root="<API-ROOT>",
api_key="<API-TOKEN>",
ib_context="<IB-CONTEXT>")
status = client.apps.runs.status('<RUN-ID>')
delete:
operationId: deleteRun
x-fern-audiences:
- public
tags:
- runs
summary: Delete run
description: Deletes a specified run and optionally its associated database data, input files, output files, and logs. This is an asynchronous operation that must be [checked for completion.](/api-sdk/api-reference/jobs/job-status)
parameters:
- $ref: '#/components/parameters/run_id'
- $ref: '#/components/parameters/ib_context'
- in: query
name: delete_db_data
schema:
type: boolean
default: true
description: Delete the run's database data.
- in: query
name: delete_input
schema:
type: boolean
default: true
description: Delete the run's input files.
- in: query
name: delete_output
schema:
type: boolean
default: true
description: Delete the run's output files.
- in: query
name: delete_logs
schema:
type: boolean
default: true
description: Delete the run's logs.
responses:
'202':
description: Run deleted successfully.
content:
application/json:
schema:
type: object
properties:
delete_input_dir_job_id:
type: string
description: Job ID for deleting the input directory.
nullable: true
delete_output_dir_job_id:
type: string
description: Job ID for deleting the output directory.
nullable: true
delete_log_dir_job_id:
type: string
description: Job ID for deleting the log directory.
nullable: true
default:
description: Error response.
content:
application/json:
schema:
$ref: '#/components/schemas/error'
x-fern-examples:
- code-samples:
- sdk: curl
code: |
curl -X DELETE "${API_ROOT}/v2/apps/runs/<RUN-ID>" \
-H "Authorization: Bearer ${API_TOKEN}"\
-H "IB-Context: ${IB-CONTEXT}"
- sdk: python
code: |
# AI Hub Python SDK example
from aihub import AIHub
client = AIHub(api_root="<API-ROOT>",
api_key="<API-TOKEN>",
ib_context="<IB-CONTEXT>")
resp = client.apps.runs.delete("<RUN-ID>")
job_ids = [
resp.delete_input_dir_job_id,
resp.delete_output_dir_job_id,
resp.delete_log_dir_job_id
]
# Remove empty job IDs
job_ids = [job_id for job_id in job_ids if job_id]
# Poll for job completion
while job_ids:
for job_id in job_ids[:]:
job_status = client.jobs.status(job_id)
if job_status.state == 'COMPLETE':
job_ids.remove(job_id)
time.sleep(5)
/v2/apps/runs/{run_id}/results:
get:
operationId: getRunResults
x-fern-audiences:
- public
tags:
- runs
summary: Get run results
description: |
Get the results of a completed run.
<Info>
This API operation might return field names that differ from those in the Build project.
The operation converts field names to valid Python variable names by:
* Allowing only letters, numbers, and underscores
* Requiring names to start with a letter or underscore
* Replacing invalid characters with underscores
* Converting single underscores to double underscores
Examples:
* `due date` → `due_date`
* `driver's license` → `driver_s_license`
* `3rd category` → `_3rd_category`
* `secret_id` → `secret__id`
These changes apply only to field names in the API response. The field names in the Build project are not changed.
</Info>
parameters:
- $ref: '#/components/parameters/run_id'
- in: query
name: include_review_results
schema:
type: boolean
default: false
description: |
Whether to include human review details in the results. When set to `true`, details such as review status and edits at the run or document level and at the extracted field level are included.
The following values are returned at the run or document level:
- `review_completed`
- `files/documents/review_completed`
- `files/documents/class_edit_history`
- `files/documents/class_edit_history/timestamp`
- `files/documents/class_edit_history/user_id`
- `files/documents/class_edit_history/modifications`
- `files/documents/class_edit_history/modifications/message`
The following values are returned at the extracted field level:
- `edit_history`
- `files/edit_history/timestamp`
- `files/edit_history/user_id`
- `files/edit_history/modifications`
- `files/edit_history/modifications/message`
See the response schema for details and descriptions.
<Note>The review process can include manually correcting values. This endpoint doesn't support returning the original and corrected values.</Note>
- in: query
name: include_confidence_scores
schema:
type: boolean
default: false
description: |
Whether to include confidence scores in the results. When set to `true`, classification confidence scores at the run or document level and extraction confidence scores at the extracted field level are included.
The following values are returned at the run or document level:
- `files/documents/classification_confidence/ocr`
The following values are returned at the extracted field level:
- `confidence/model`
See the response schema for details and descriptions.
- in: query
name: include_validation_results
schema:
type: boolean
default: false
description: |
Whether to include validation status in the results. When set to `true`, validation results at the run or document level and extracted field level are included.
The following values are returned at the run or document level:
- `files/validations/final_result_pass`
The following values are returned at the extracted field level:
- `validations/valid`
- `validations/alerts`
See the response schema for details and descriptions.
- in: query
name: include_source_info
schema:
type: boolean
default: false
description: |