-
Notifications
You must be signed in to change notification settings - Fork 0
/
coda-io-original-openapi.yaml
14033 lines (13480 loc) · 442 KB
/
coda-io-original-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:
version: 1.4.17
title: Coda API
license:
name: Coda Developer Terms
url: https://coda.io/trust/developer
description: >
# Introduction
The Coda API is a RESTful API that lets you programmatically interact with
Coda docs:
* List and search Coda docs
* Create new docs and copy existing ones
* Share and publish docs
* Discover pages, tables, formulas, and controls
* Read, insert, upsert, update, and delete rows
As we update and release newer versions of the API, we reserve the right to
remove
older APIs and functionality with a 3-month deprecation notice. We will post
about such changes as well as announce
new features in the [Developers
Central](https://community.coda.io/c/developers-central) section of our
Community,
and update the [API updates](https://coda.io/api-updates) doc.
# Getting Started
Our [Getting Started
Guide](https://coda.io/@oleg/getting-started-guide-coda-api) helps you learn
the
basic of working with the API and shows a few ways you can use it. Check it
out, and learn how to:
- Read data from Coda tables and write back to them
- Build a one-way sync from one Coda doc to another
- Automate reminders
- Sync your Google Calendar to Coda
# Using the API
Coda's REST API is designed to be straightforward to use. You can use the
language and platform of your choice to
make requests. To get a feel for the API, you can also use a tool like
[Postman](https://www.getpostman.com/) or
[Insomnia](https://insomnia.rest/).
## API Endpoint
This API uses a base path of `https://coda.io/apis/v1`.
## Resource IDs and Links
Each resource instance retrieved via the API has the following fields:
- `id`: The resource's immutable ID, which can be used to refer to it within its context
- `type`: The type of resource, useful for identifying it in a heterogenous collection of results
- `href`: A fully qualified URI that can be used to refer to and get the latest details on the resource
Most resources can be queried by their name or ID. We recommend sticking
with IDs where possible, as names are
fragile and prone to being changed by your doc's users.
### List Endpoints
Endpoints supporting listing of resources have the following fields:
- `items`: An array containing the listed resources, limited by the `limit` or `pageToken` query parameters
- `nextPageLink`: If more results are available, an API link to the next page of results
- `nextPageToken`: If more results are available, a page token that can be passed into the `pageToken` query parameter
**The maximum page size may change at any time, and may be different for
different endpoints.** Please do not rely on it
for any behavior of your application. If you pass a `limit` parameter that
is larger than our maximum allowed limit,
we will only return as many results as our maximum limit. You should look
for the presence of the `nextPageToken` on the
response to see if there are more results available, rather than relying on
a result set that matches your provided limit.
To fetch a subsequent page of results, pass the `pageToken` parameter. Set
this parameter to the value given to you as the `nextPageToken`
in a page response. If no value is provided, there are no more results
available. You only need to pass the `pageToken` to get
the next page of results, you don't need to pass any of the parameters from
your original request, as they are all
implied by the `pageToken`. Any other parameters provided alongside a
`pageToken` will be ignored.
### Doc IDs
While most object IDs will have to be discovered via the API, you may find
yourself frequently wanting to get the
ID of a specific Coda doc.
Here's a handy tool that will extract it for you. (See if you can find the
pattern!)
<form>
<fieldset style="margin: 0px 25px 25px 25px; display: inline;">
<legend>Doc ID Extractor</legend>
<input type="text" id="de_docUrl" placeholder="Paste in a Coda doc URL"
style="width: 250px; padding: 8px; margin-right: 20px;" />
<span>
Your doc ID is:
<input id="de_docId" readonly="true"
style="width: 150px; padding: 8px; font-family: monospace; border: 1px dashed gray;" />
</fieldset>
</form>
<script>
(() => {
const docUrl = document.getElementById('de_docUrl');
const docId = document.getElementById('de_docId');
docUrl.addEventListener('input', () => {
docId.value = (docUrl.value.match(/_d([\w-]+)/) || [])[1] || '';
});
docId.addEventListener('mousedown', () => docId.select());
docId.addEventListener('click', () => docId.select());
})();
</script>
## Rate Limiting
The Coda API sets a reasonable limit on the number of requests that can be
made per minute. Once this limit is
reached, calls to the API will start returning errors with an HTTP status
code of 429.
These are the current rate limits. They are subject to change at any time
without notice. For robustness,
all API scripts should check for HTTP 429 Too Many Requests errors and back
off and retry the request.
Limits apply per-user across all endpoints that share the same limit and
across all docs.
Reading data (with the exceptions below): 100 requests per 6 seconds
<br/>
Writing data (POST/PUT/PATCH): 10 requests per 6 seconds
<br/>
Writing doc content data (POST/PUT/PATCH): 5 requests per 10 seconds
<br/>
Listing docs: 4 requests per 6 seconds
<br/>
Reading analytics: 100 requests per 6 seconds
## Consistency
While edits made in Coda are shared with other collaborators in real-time,
it can take a few seconds for them to
become available via the API. You may also notice that changes made via the
API, such as updating a row, are not
immediate. These endpoints all return an HTTP 202 status code, instead of a
standard 200, indicating that the
edit has been accepted and queued for processing. This generally takes a few
seconds, and the edit may fail if
invalid. Each such edit will return a `requestId` in the response, and you
can pass this `requestId` to the
[`#getMutationStatus`](#operation/getMutationStatus) endpoint to find out if
it has been applied.
Similarly, when you get doc data from the API (rows, pages, columns, etc),
the data you receive comes from
the most recent "snapshot" of the doc, which might be slightly stale
relative to the data you observe in
your browser. If you want to ensure that the data you receive is up to date
and are ok getting an error if not,
you can pass this header in your request: `X-Coda-Doc-Version: latest`. If
the API's view of the doc is
not up to date, the API will return an HTTP 400 response.
## Volatile Formulas
Coda exposes a number of "volatile" formulas, as as `Today()`, `Now()`, and
`User()`. When used in a live Coda
doc, these formulas affect what's visible in realtime, tailored to the
current user.
Such formulas behave differently with the API. Time-based values may only be
current to the last edit made to the
doc. User-based values may be blank or invalid.
## Free and Paid Workspaces
We make the Coda API available to all of our users free of charge, in both
free and paid workspaces. However, API
usage is subject to the role of the user associated with the API token in
the workspace applicable to each API
request. What this means is:
- For the [`#createDoc`](#operation/createDoc) endpoint specifically, the
owner of the API token must be a Doc
Maker (or Admin) in the workspace. If the "Any member can create docs" option in enabled in the workspace
settings, they can be an Editor and will get auto-promoted to Doc Maker upon using this endpoint. Lastly, if in
addition, the API key owner matches the "Auto-join email domains" setting, they will be auto-added to the
workspace and promoted to Doc Maker upon using this endpoint
This behavior applies to the API as well as any integrations that may use
it, such as Zapier.
## Examples
To help you get started, this documentation provides code examples in
Python, Unix shell, and Google Apps Script.
These examples are based on a simple doc that looks something like this:
![](https://cdn.coda.io/external/img/api_example_doc.png)
### Python examples
These examples use Python 3.6+. If you don't already have the `requests`
module, use `pip` or `easy_install` to
get it.
### Shell examples
The shell examples are intended to be run in a Unix shell. If you're on
Windows, you will need to install
[WSL](https://docs.microsoft.com/en-us/windows/wsl/install-win10).
These examples use the standard cURL utility to pull from the API, and then
process it with `jq` to extract and
format example output. If you don't already have it, you can either [install
it](https://stedolan.github.io/jq/)
or run the command without it to see the raw JSON output.
### Google Apps Script examples
![](https://cdn.coda.io/external/img/api_gas.png)
[Google Apps Script](https://script.google.com/) makes it easy to write code
in a JavaScript-like syntax and
easily access many Google products with built-in libraries. You can set up
your scripts to run periodically,
which makes it a good environment for writing tools without maintaining your
own server.
Coda provides a library for Google Apps Script. To use it, go into
`Resources -> Libraries...` and enter the
following library ID:
`15IQuWOk8MqT50FDWomh57UqWGH23gjsWVWYFms3ton6L-UHmefYHS9Vl`. If you want to
see the
library's source code, it's available
[here](https://script.google.com/d/15IQuWOk8MqT50FDWomh57UqWGH23gjsWVWYFms3ton6L-UHmefYHS9Vl/edit).
Google provides autocomplete for API functions as well as generated docs.
You can access these docs via the
Libraries dialog by clicking on the library name. Required parameters that
would be included in the URL path are
positional arguments in each of these functions, followed by the request
body, if applicable. All remaining
parameters can be specified in the options object.
## OpenAPI/Swagger Spec
In an effort to standardize our API and make it accessible, we offer an
OpenAPI 3.0 specification:
- [OpenAPI 3.0 spec - YAML](https://coda.io/apis/v1/openapi.yaml)
- [OpenAPI 3.0 spec - JSON](https://coda.io/apis/v1/openapi.json)
#### Postman collection
To get started with prototyping the API quickly in Postman, you can use one
of links above to import the Coda API
into a collection. You'll then need to set the [appropriate
header](#section/Authentication) and environment
variables.
## Client libraries
We do not currently support client libraries apart from Google Apps Script.
To work with the Coda API, you can
either use standard network libraries for your language, or use the
appropriate Swagger Generator tool to
auto-generate Coda API client libraries for your language of choice. We do
not provide any guarantees that these
autogenerated libraries are compatible with our API (e.g., some libraries
may not work with Bearer
authentication).
### OpenAPI 3.0
[Swagger Generator 3](https://generator3.swagger.io/) (that link takes you
to the docs for the generator API) can
generate client libraries for [these
languages](https://generator3.swagger.io/v2/clients). It's relatively new
and thus only has support for a limited set of languages at this time.
### Third-party client libraries
Some members of our amazing community have written libraries to work with
our API. These aren't officially
supported by Coda, but are listed here for convenience. (Please let us know
if you've written a library and would
like to have it included here.)
- [PHP](https://github.com/danielstieber/CodaPHP) by Daniel Stieber
- [Node-RED](https://github.com/serene-water/node-red-contrib-coda-io) by
Mori Sugimoto
- [NodeJS](https://www.npmjs.com/package/coda-js) by Parker McMullin
- [Ruby](https://rubygems.org/gems/coda_docs/) by Carlos Muñoz at Getro
- [Python](https://github.com/Blasterai/codaio) by Mikhail Beliansky
- [Go](https://github.com/artsafin/coda-schema-generator) by Artur Safin
termsOfService: https://coda.io/trust/tos
contact:
name: API Support
url: https://coda.io
email: help+api@coda.io
x-logo:
url: https://cdn.coda.io/external/img/apilogo.png
backgroundColor: transparent
altText: Coda API
href: '#'
servers:
- url: https://coda.io/apis/v1
description: Coda API (v1)
tags:
- name: Account
description: >
At this time, the API exposes some limited information about your account.
However, `/whoami` is a good endpoint to hit to verify that you're hitting
the API correctly and that your token is working as expected.
- name: Analytics
description: This API offers analytics data for your docs and Packs over time.
- name: Automations
description: This API allows you to trigger automations.
- name: Columns
description: >
While columns in Coda have user-friendly names, they also have immutable
IDs that are used when reading and writing rows. These endpoints let you
query the columns in a table and get basic information about them.
- name: Controls
description: >
Controls provide a user-friendly way to input a value that can affect
other parts of the doc. This API lets you list controls and get their
current values.
- name: Docs
description: >
Coda docs are foundational, top-level collaborative projects that contain
pages. The API lets you list and search your docs to obtain basic metadata
like titles and ownership information.
- name: Formulas
description: >
Formulas can be great for performing one-off computations, or used with
tables and other formulas to compute a single value. With this API, you
can discover formulas in a doc and obtain computed results.
- name: Miscellaneous
description: >
These endpoints wouldn't fit anywhere else, but you may find them useful
when working with Coda.
- name: Packs
description: >
This API allows you to manage Packs that you have developed as well as
list publicly available Coda packs.
- name: Pages
description: >
Pages in Coda offer canvases containing rich text, tables, controls, and
other objects. At this time, this API lets you list and access pages in a
doc.
- name: Permissions
description: This API lets you manage sharing and permissions for your docs.
- name: Publishing
description: >
Coda docs can be published publicly and associated with categories to help
the world discover them. This API lets you manage the publishing settings
of your docs.
- name: Rows
description: >
You'll likely use this part of the API the most. These endpoints let you
retrieve row data from tables in Coda as well as create, upsert, update,
and delete them. Most of these endpoints work for both base tables and
views, but for inserting/upsering rows, you must use a base table.
- name: Tables and Views
description: >
If you're here, you know the power of tables in Coda. This API lets you
list the tables and views in a Coda doc and obtain basic schema
information.
- name: Workspaces
description: >
This API allows you to manage your workspace's membership and get
analytics on membership over time.
x-tagGroups:
- name: Docs
tags:
- Docs
- Permissions
- Publishing
- name: Doc Structure
tags:
- Pages
- Automations
- name: Tables and Views
tags:
- Tables
- Columns
- Rows
- name: Formulas & Controls
tags:
- Formulas
- Controls
- name: Miscellaneous
tags:
- Account
- Analytics
- Miscellaneous
paths:
/categories:
get:
summary: Get doc categories
description: Gets all available doc categories.
operationId: listCategories
tags:
- Publishing
responses:
'200':
description: List of doc categories
content:
application/json:
schema:
$ref: '#/components/schemas/DocCategoryList'
'401':
$ref: '#/components/responses/UnauthorizedError'
'404':
$ref: '#/components/responses/NotFoundError'
'429':
$ref: '#/components/responses/TooManyRequestsError'
x-codeSamples:
- label: Python 3.7
lang: python
source: |
import requests
headers = {'Authorization': 'Bearer <your API token>'}
uri = f'https://coda.io/apis/v1/categories'
res = requests.get(uri, headers=headers).json()
print(f'Category count: {res["categories"].length}')
# => Category count: 10
- label: Shell
lang: shell
source: |
curl -s -H 'Authorization: Bearer <your API token>' \
'https://coda.io/apis/v1/categories' |
jq .categories.name
# => "10"
- label: Google Apps Script
lang: javascript
source: |
// Import the CodaAPI library via Resource->Libraries...:
// 15IQuWOk8MqT50FDWomh57UqWGH23gjsWVWYFms3ton6L-UHmefYHS9Vl
CodaAPI.authenticate('<your API token>');
var categories = CodaAPI.listCategories();
Logger.log('Category count: ' + categories.categories.length);
// => Category count: 10
/docs:
get:
summary: List available docs
description: >
Returns a list of Coda docs accessible by the user. These are returned
in the same order as on the docs page: reverse chronological by the
latest event relevant to the user (last viewed, edited, or shared).
operationId: listDocs
tags:
- Docs
parameters:
- name: isOwner
in: query
description: Show only docs owned by the user.
schema:
type: boolean
- name: isPublished
in: query
description: Show only published docs.
schema:
type: boolean
- $ref: '#/components/parameters/query'
- name: sourceDoc
in: query
description: Show only docs copied from the specified doc ID.
schema:
type: string
- name: isStarred
in: query
description: >-
If true, returns docs that are starred. If false, returns docs that
are not starred.
schema:
type: boolean
- name: inGallery
in: query
description: Show only docs visible within the gallery.
schema:
type: boolean
- name: workspaceId
in: query
description: Show only docs belonging to the given workspace.
schema:
type: string
- name: folderId
in: query
description: Show only docs belonging to the given folder.
schema:
type: string
- $ref: '#/components/parameters/limit'
- $ref: '#/components/parameters/pageToken'
responses:
'200':
description: List of Coda docs matching the query.
content:
application/json:
schema:
$ref: '#/components/schemas/DocList'
'401':
$ref: '#/components/responses/UnauthorizedError'
'403':
$ref: '#/components/responses/ForbiddenError'
'404':
$ref: '#/components/responses/NotFoundError'
'429':
$ref: '#/components/responses/TooManyRequestsError'
x-codeSamples:
- label: Python 3.7
lang: python
source: |
import requests
headers = {'Authorization': 'Bearer <your API token>'}
uri = 'https://coda.io/apis/v1/docs'
params = {
'isOwner': True,
'query': 'New',
}
res = requests.get(uri, headers=headers, params=params).json()
print(f'First doc is: {res["items"][0]["name"]}')
# => First doc is: New Document
- label: Shell
lang: shell
source: |
curl -s -H 'Authorization: Bearer <your API token>' \
'https://coda.io/apis/v1/docs' |
jq .items[0].name
# => "New Document"
- label: Google Apps Script
lang: javascript
source: |
// Import the CodaAPI library via Resource->Libraries...:
// 15IQuWOk8MqT50FDWomh57UqWGH23gjsWVWYFms3ton6L-UHmefYHS9Vl
CodaAPI.authenticate('<your API token>');
var docs = CodaAPI.listDocs().items;
Logger.log('First doc is ' + docs[0].name);
// => First doc is: New Document
post:
summary: Create doc
description: >
Creates a new Coda doc, optionally copying an existing doc. Note that
creating a doc requires you to be a Doc Maker in the applicable
workspace (or be auto-promoted to one).
operationId: createDoc
tags:
- Docs
requestBody:
description: Parameters for creating the doc.
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/DocCreate'
responses:
'201':
description: Info about the created doc.
content:
application/json:
schema:
$ref: '#/components/schemas/DocumentCreationResult'
'400':
$ref: '#/components/responses/BadRequestError'
'401':
$ref: '#/components/responses/UnauthorizedError'
'403':
$ref: '#/components/responses/ForbiddenError'
'429':
$ref: '#/components/responses/TooManyRequestsError'
x-codeSamples:
- label: Python 3.7
lang: python
source: |
import requests
headers = {'Authorization': 'Bearer <your API token>'}
uri = f'https://coda.io/apis/v1/docs'
payload = {
'title': 'Project Tracker',
}
req = requests.post(uri, headers=headers, json=payload)
req.raise_for_status() # Throw if there was an error.
res = req.json()
print(f'New doc created with name "{res["name"]}"')
# => New doc created with name "Project Tracker"
- label: Shell
lang: shell
source: >
curl -s -H 'Authorization: Bearer <your API token>' -X POST -H
"Content-Type: application/json" \
-d '{"title": "Project Tracker"}' \
'https://coda.io/apis/v1/docs' |
jq .name
# => "Project Tracker"
- label: Google Apps Script
lang: javascript
source: |
// Import the CodaAPI library via Resource->Libraries...:
// 15IQuWOk8MqT50FDWomh57UqWGH23gjsWVWYFms3ton6L-UHmefYHS9Vl
CodaAPI.authenticate('<your API token>');
var res = CodaAPI.createDoc({title: 'Project Tracker'});
Logger.log('New doc created with name ' + res.name);
// => First doc in the results is: New Document
/docs/{docId}:
get:
summary: Get info about a doc
description: Returns metadata for the specified doc.
operationId: getDoc
tags:
- Docs
parameters:
- $ref: '#/components/parameters/docId'
responses:
'200':
description: Basic Coda doc metadata.
content:
application/json:
schema:
$ref: '#/components/schemas/Doc'
'401':
$ref: '#/components/responses/UnauthorizedError'
'403':
$ref: '#/components/responses/ForbiddenError'
'404':
$ref: '#/components/responses/NotFoundError'
'429':
$ref: '#/components/responses/TooManyRequestsError'
x-codeSamples:
- label: Python 3.7
lang: python
source: |
import requests
headers = {'Authorization': 'Bearer <your API token>'}
uri = f'https://coda.io/apis/v1/docs/<doc ID>'
res = requests.get(uri, headers=headers).json()
print(f'The name of the doc is {res["name"]}')
# => The name of the doc is New Document
- label: Shell
lang: shell
source: |
curl -s -H 'Authorization: Bearer <your API token>' \
'https://coda.io/apis/v1/docs/<doc ID>' |
jq .name
# => "New Document"
- label: Google Apps Script
lang: javascript
source: |
// Import the CodaAPI library via Resource->Libraries...:
// 15IQuWOk8MqT50FDWomh57UqWGH23gjsWVWYFms3ton6L-UHmefYHS9Vl
CodaAPI.authenticate('<your API token>');
var docInfo = CodaAPI.getDoc('<doc ID>');
Logger.log('The name of the doc is ' + docInfo.name);
// => The name of the doc is New Document
delete:
summary: Delete doc
description: Deletes a doc.
operationId: deleteDoc
tags:
- Docs
parameters:
- $ref: '#/components/parameters/docId'
responses:
'202':
description: A result indicating that the doc was deleted.
content:
application/json:
schema:
$ref: '#/components/schemas/DocDelete'
'401':
$ref: '#/components/responses/UnauthorizedError'
'403':
$ref: '#/components/responses/ForbiddenError'
'404':
$ref: '#/components/responses/NotFoundError'
'429':
$ref: '#/components/responses/TooManyRequestsError'
x-codeSamples:
- label: Python 3.7
lang: python
source: |
import requests
headers = {'Authorization': 'Bearer <your API token>'}
uri = f'https://coda.io/apis/v1/docs/<doc ID>'
res = requests.delete(uri, headers=headers).json()
- label: Shell
lang: shell
source: |
curl -s -X DELETE -H 'Authorization: Bearer <your API token>' \
'https://coda.io/apis/v1/docs/<doc ID>' |
- label: Google Apps Script
lang: javascript
source: |
// Import the CodaAPI library via Resource->Libraries...:
// 15IQuWOk8MqT50FDWomh57UqWGH23gjsWVWYFms3ton6L-UHmefYHS9Vl
CodaAPI.authenticate('<your API token>');
var docInfo = CodaAPI.deleteDoc('<doc ID>');
// => The given doc is now deleted
patch:
summary: Update doc
description: >-
Updates metadata for a doc. Note that updating a doc title requires you
to be a Doc Maker in the applicable workspace.
operationId: updateDoc
tags:
- Docs
parameters:
- $ref: '#/components/parameters/docId'
requestBody:
description: Parameters for updating the doc.
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/DocUpdate'
responses:
'200':
description: Basic Coda doc metadata.
content:
application/json:
schema:
$ref: '#/components/schemas/DocUpdateResult'
'400':
$ref: '#/components/responses/BadRequestError'
'401':
$ref: '#/components/responses/UnauthorizedError'
'403':
$ref: '#/components/responses/ForbiddenError'
'404':
$ref: '#/components/responses/NotFoundError'
'429':
$ref: '#/components/responses/TooManyRequestsError'
x-codeSamples:
- label: Python 3.7
lang: python
source: |
import requests
headers = {'Authorization': 'Bearer <your API token>'}
uri = f'https://coda.io/apis/v1/docs/<doc ID>'
payload = {
'title': 'New Doc Title',
}
req = requests.patch(uri, headers=headers, json=payload)
- label: Shell
lang: shell
source: >
curl -s -H 'Authorization: Bearer <your API token>' -X PATCH -H
"Content-Type: application/json" \
-d '{"title": "New Doc Title"}' \
'https://coda.io/apis/v1/docs/<doc ID>'
- label: Google Apps Script
lang: javascript
source: |
// Import the CodaAPI library via Resource->Libraries...:
// 15IQuWOk8MqT50FDWomh57UqWGH23gjsWVWYFms3ton6L-UHmefYHS9Vl
CodaAPI.authenticate('<your API token>');
CodaAPI.updateDoc(<doc ID>, {title: "New Doc Title"});
/docs/{docId}/acl/metadata:
get:
summary: Get sharing metadata
description: Returns metadata associated with sharing for this Coda doc.
operationId: getSharingMetadata
tags:
- Permissions
parameters:
- $ref: '#/components/parameters/docId'
responses:
'200':
description: Metadata associated with sharing permissions for a doc.
content:
application/json:
schema:
$ref: '#/components/schemas/AclMetadata'
'401':
$ref: '#/components/responses/UnauthorizedError'
'403':
$ref: '#/components/responses/ForbiddenError'
'404':
$ref: '#/components/responses/NotFoundError'
'429':
$ref: '#/components/responses/TooManyRequestsError'
x-codeSamples:
- label: Python 3.7
lang: python
source: |
import requests
headers = {'Authorization': 'Bearer <your API token>'}
uri = f'https://coda.io/apis/v1/docs/<doc ID>/acl/metadata'
res = requests.get(uri, headers=headers).json()
print(f'Can I share this doc with others? {res["canShare"]}')
# => Can I share this doc with others? true
- label: Shell
lang: shell
source: |
curl -s -H 'Authorization: Bearer <your API token>' \
'https://coda.io/apis/v1/docs/<doc ID>/acl/metadata' |
jq .canShare
# => "true"
- label: Google Apps Script
lang: javascript
source: >
// Import the CodaAPI library via Resource->Libraries...:
// 15IQuWOk8MqT50FDWomh57UqWGH23gjsWVWYFms3ton6L-UHmefYHS9Vl
CodaAPI.authenticate('<your API token>');
var docSharingMetadata = CodaAPI.getSharingMetadata('<doc ID>');
Logger.log('Can I share this doc with others? ' +
docSharingMetadata.canShare);
// => Can I share this doc with others? true
/docs/{docId}/acl/permissions:
get:
summary: List permissions
description: Returns a list of permissions for this Coda doc.
operationId: getPermissions
tags:
- Permissions
parameters:
- $ref: '#/components/parameters/docId'
- $ref: '#/components/parameters/limit'
- $ref: '#/components/parameters/pageToken'
responses:
'200':
description: List of permissions for a doc.
content:
application/json:
schema:
$ref: '#/components/schemas/Acl'
'401':
$ref: '#/components/responses/UnauthorizedError'
'403':
$ref: '#/components/responses/ForbiddenError'
'404':
$ref: '#/components/responses/NotFoundError'
'429':
$ref: '#/components/responses/TooManyRequestsError'
x-codeSamples:
- label: Python 3.7
lang: python
source: >
import requests
headers = {'Authorization': 'Bearer <your API token>'}
uri = f'https://coda.io/apis/v1/docs/<doc ID>/acl/permissions'
res = requests.get(uri, headers=headers).json()