-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
13397 lines (12050 loc) · 939 KB
/
index.html
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Agave Platform Developer Documentation</title>
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico">
<!-- <script src="https://use.typekit.net/squ8frf.js"></script>
<script>try{Typekit.load({ async: true });}catch(e){}</script> -->
<link href="stylesheets/screen.css" rel="stylesheet" type="text/css" media="screen" />
<link href="stylesheets/print.css" rel="stylesheet" type="text/css" media="print" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<!-- <script src="javascripts/jquery.min.js" type="text/javascript"></script> -->
<script src="javascripts/all.js" type="text/javascript"></script>
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-43163231-12', 'auto');
ga('require', 'eventTracker');
ga('require', 'outboundLinkTracker');
ga('require', 'urlChangeTracker');
ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<script src="javascripts/autotrack.js" type="text/javascript" async="true"></script>
<script>
$(function() {
setupLanguages(["shell","plaintext"]);
});
</script>
<style>
.js #fouc { display: none; }
</style>
<script type="text/javascript">
document.documentElement.className = 'js';
</script>
</head>
<body class="index">
<a href="#" id="nav-button">
<span>
NAV
<img src="images/navbar.png" />
</span>
</a>
<div id="fouc">
<div class="tocify-wrapper">
<img class="menu-logo" src="images/agave-docs-logo.png" />
<div class="lang-selector">
<a href="#" data-language-name="shell">cURL</a>
<a href="#" data-language-name="plaintext">CLI</a>
</div>
<div class="search">
<input type="text" class="search" id="input-search" placeholder="Search">
</div>
<ul class="search-results"></ul>
<div id="toc">
</div>
<ul class="toc-footer">
<li><a href='https://public.agaveapi.co/create_account' target='_blank'>Create an Account</a></li>
<li><a href='https://bitbucket.org/agaveapi/agave-flat/src/master/CHANGELOG.md' target='_blank'>CHANGELOG</a></li>
<li><a href='http://status.agaveapi.co' target='_blank'>Status Page</a></li>
<li><a href='http://support.agaveapi.co' target='_blank'>Issues</a></li>
<li><a href='http://support.agaveapi.co' target='_blank'>Knowledge Base</a></li>
</ul>
</div>
<div class="page-wrapper">
<div class="dark-box"></div>
<div class="content">
<h1 id="introduction">Introduction</h1>
<pre class="highlight json"><code><span class="w"> </span><span class="err">/$$$$$$</span><span class="w">
</span><span class="err">/$$__</span><span class="w"> </span><span class="err">$$</span><span class="w">
</span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">\</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">/$$$$$$</span><span class="w"> </span><span class="err">/$$$$$$</span><span class="w"> </span><span class="err">/$$</span><span class="w"> </span><span class="err">/$$</span><span class="w"> </span><span class="err">/$$$$$$</span><span class="w">
</span><span class="err">|</span><span class="w"> </span><span class="err">$$$$$$$$</span><span class="w"> </span><span class="err">/$$__</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|____</span><span class="w"> </span><span class="err">$$|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">/$$//$$__</span><span class="w"> </span><span class="err">$$</span><span class="w">
</span><span class="err">|</span><span class="w"> </span><span class="err">$$__</span><span class="w"> </span><span class="err">$$|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">\</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">/$$$$$$$</span><span class="w"> </span><span class="err">\</span><span class="w"> </span><span class="err">$$/$$/|</span><span class="w"> </span><span class="err">$$$$$$$$</span><span class="w">
</span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">/$$__</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">\</span><span class="w"> </span><span class="err">$$$/</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$_____/</span><span class="w">
</span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$|</span><span class="w"> </span><span class="err">$$$$$$$|</span><span class="w"> </span><span class="err">$$$$$$$</span><span class="w"> </span><span class="err">\</span><span class="w"> </span><span class="err">$/</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$$$$$$</span><span class="w">
</span><span class="err">|__/</span><span class="w"> </span><span class="err">|__/</span><span class="w"> </span><span class="err">\____</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">\_______/</span><span class="w"> </span><span class="err">\_/</span><span class="w"> </span><span class="err">\_______/</span><span class="w">
</span><span class="err">/$$</span><span class="w"> </span><span class="err">\</span><span class="w"> </span><span class="err">$$</span><span class="w">
</span><span class="err">|</span><span class="w"> </span><span class="err">$$$$$$/</span><span class="w">
</span><span class="err">\______/</span><span class="w">
</span></code></pre>
<p>The Agave Platform (<a href="http://agaveapi.co">http://agaveapi.co</a>) is an open source, science-as-a-service API platform for powering your digital lab. Agave allows you to bring together your public, private, and shared high performance
computing (HPC), high throughput computing (HTC), Cloud, and Big Data resources under a single, web-friendly REST API.</p>
<ul>
<li>Run code</li>
<li>Manage data</li>
<li>Collaborate meaningfully</li>
<li>Integrate anywhere</li>
</ul>
<p>The Agave documentation site contains documentation, guides, tutorials, and lots of examples to help you build your own digital lab.</p>
<aside class="info">If you came here looking for a UI to interact with the platform and kick the tires, please see our reference web application, Agave ToGo, at <a href="http://togo.agaveapi.co/">http://togo.agaveapi.co/</a>.</aside>
<h2 id="conventions">Conventions</h2>
<p>Throughout the documentation you will regularly encounter the following variables. These represent user-specific values that should be replaced when attempting any of the calls using your account. Once you log into this site, these values will be replaced with values appropriate for you to use when copying and pasting the examples on your own.</p>
<table>
<thead>
<tr>
<th>Variable</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td>${API_HOST}</td>
<td>Base hostname of the API. </td>
<td>public.agaveapi.co</td>
</tr>
<tr>
<td>${API_VERSION}</td>
<td>Version of the API endpoint.</td>
<td>v2</td>
</tr>
<tr>
<td>${API_USERNAME}</td>
<td>Username of the current user.</td>
<td>nryan</td>
</tr>
<tr>
<td>${API_KEY}</td>
<td>Client key used to request an access token from the Agave Auth service.</td>
<td>hZ_z3f4Hf3CcgvGoMix0aksN4BOD6</td>
</tr>
<tr>
<td>${API_SECRET}</td>
<td>Client secret used to request an access token from the Agave Auth service.</td>
<td>gTgpCecqtOc6Ao3GmZ_FecVSSV8a</td>
</tr>
<tr>
<td>${API_TOKEN}</td>
<td></td>
<td>de32225c235cf47b9965997270a1496c</td>
</tr>
</tbody>
</table>
<h3 id="json-notation">JSON Notation</h3>
<pre class="highlight json"><code><span class="p">{</span><span class="w">
</span><span class="nt">"active"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
</span><span class="nt">"created"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2014-09-04T16:59:33.000-05:00"</span><span class="p">,</span><span class="w">
</span><span class="nt">"frequency"</span><span class="p">:</span><span class="w"> </span><span class="mi">60</span><span class="p">,</span><span class="w">
</span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"0001409867973952-5056a550b8-0001-014"</span><span class="p">,</span><span class="w">
</span><span class="nt">"internalUsername"</span><span class="p">:</span><span class="w"> </span><span class="kc">null</span><span class="p">,</span><span class="w">
</span><span class="nt">"lastCheck"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
</span><span class="p">{</span><span class="w">
</span><span class="nt">"created"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2014-10-02T13:03:25.000-05:00"</span><span class="p">,</span><span class="w">
</span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"0001412273000497-5056a550b8-0001-015"</span><span class="p">,</span><span class="w">
</span><span class="nt">"message"</span><span class="p">:</span><span class="w"> </span><span class="kc">null</span><span class="p">,</span><span class="w">
</span><span class="nt">"result"</span><span class="p">:</span><span class="w"> </span><span class="s2">"PASSED"</span><span class="p">,</span><span class="w">
</span><span class="nt">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"STORAGE"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="p">{</span><span class="w">
</span><span class="nt">"created"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2014-10-02T13:03:25.000-05:00"</span><span class="p">,</span><span class="w">
</span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"0001411825368981-5056a550b8-0001-015"</span><span class="p">,</span><span class="w">
</span><span class="nt">"message"</span><span class="p">:</span><span class="w"> </span><span class="kc">null</span><span class="p">,</span><span class="w">
</span><span class="nt">"result"</span><span class="p">:</span><span class="w"> </span><span class="s2">"FAILED"</span><span class="p">,</span><span class="w">
</span><span class="nt">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"LOGIN"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">],</span><span class="w">
</span><span class="nt">"lastSuccess"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2014-10-02T11:03:13.000-05:00"</span><span class="p">,</span><span class="w">
</span><span class="nt">"lastUpdated"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2014-10-02T13:03:25.000-05:00"</span><span class="p">,</span><span class="w">
</span><span class="nt">"nextUpdate"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2014-10-02T14:03:15.000-05:00"</span><span class="p">,</span><span class="w">
</span><span class="nt">"owner"</span><span class="p">:</span><span class="w"> </span><span class="s2">"systest"</span><span class="p">,</span><span class="w">
</span><span class="nt">"target"</span><span class="p">:</span><span class="w"> </span><span class="s2">"demo.storage.example.com"</span><span class="p">,</span><span class="w">
</span><span class="nt">"updateSystemStatus"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
</span><span class="nt">"_links"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nt">"checks"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nt">"href"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://public.tenants.agaveapi.co/monitor/v2/0001409867973952-5056a550b8-0001-014/checks"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nt">"notifications"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nt">"href"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://public.tenants.agaveapi.co/notifications/v2/?associatedUuid=0001409867973952-5056a550b8-0001-014"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nt">"owner"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nt">"href"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://public.tenants.agaveapi.co/profiles/v2/systest"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nt">"self"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nt">"href"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://public.tenants.agaveapi.co/monitor/v2/0001409867973952-5056a550b8-0001-014"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nt">"system"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nt">"href"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://public.tenants.agaveapi.co/systems/v2/demo.storage.example.com"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
<p>When describing the JSON objects passed back and forth with the APIs, Javascript dot notation will be used to refer to individual properties. For example, consider the following JSON object.</p>
<ul>
<li><code class="prettyprint">active</code> refers to the top level <code class="prettyprint">active</code> attribute in the response object.</li>
<li><code class="prettyprint">lastCheck.[].result</code> generically refers to the result attribute contained within any of the objects contained in the <code class="prettyprint">lastCheck</code> array.</li>
<li><code class="prettyprint">lastCheck.[0].result</code> specifically refers to the result attribute contained within the first object in the <code class="prettyprint">lastCheck</code> array.</li>
<li><code class="prettyprint">_links.self.href</code> refers to the href attribute in the checks object within the <code class="prettyprint">_links</code> object.</li>
</ul>
<h3 id="versioning">Versioning</h3>
<p>The current major version of Agave is given in the URI immediately following the API resource name. For example, if the endpoint is <code class="prettyprint">https://public.tenants.agaveapi.co/jobs/v2/</code>, the API version would be <code class="prettyprint">v2</code>. The current major version of agave is v2.</p>
<h3 id="slugs">Slugs</h3>
<p>In certain situations, usually where file system paths and names are involved in some way, Agave will generate slugify object names to make them safe to use. Slugs will be created on the fly by applying the following rules:</p>
<ol>
<li>Lowercase the string</li>
<li>Replace spaces with a dash</li>
<li>Remove any special characters and punctuation that might require encoding in the URL. Allowed characters are alphanumeric characters, numbers, underscores, and periods.</li>
</ol>
<h3 id="secure-communication">Secure communication</h3>
<p>Agave uses SSL to secure communication with the clients. If HTTPS is not specified in the request, the request will be redirected to a secure channel.</p>
<h3 id="rate-limiting">Rate limiting</h3>
<p>To make the API fast for everybody, rate limits apply. Unsigned requests are processed at the lowest rate limit. Signed requests with a valid access token benefit from higher rate limits — this is true even if endpoint doesn’t require an access token to be passed in the call.</p>
<h3 id="requests">Requests</h3>
<p>The Agave API is based on <a title="REST" href="http://en.wikipedia.org/wiki/Representational_state_transfer" target="_blank">REST</a> principles: data resources are accessed via standard HTTPS requests in UTF-8 format to an API endpoint. Where possible, the API strives to use appropriate HTTP verbs for each action</p>
<table>
<thead>
<tr>
<th>Verb</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>GET</td>
<td>Used for retrieving resources.</td>
</tr>
<tr>
<td>POST</td>
<td>Used for creating resources.</td>
</tr>
<tr>
<td>PUT</td>
<td>Used for manipulating resources or collections.</td>
</tr>
<tr>
<td>DELETE</td>
<td>Used for deleting resources. </td>
</tr>
</tbody>
</table>
<h4 id="standard-query-parameters">Standard query parameters</h4>
<p>Several URL query parameters are common across all services. The following table lists them for reference</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Values</th>
<th>Purpose</th>
</tr>
</thead>
<tbody>
<tr>
<td>offset</td>
<td>integer (zero-based)</td>
<td>Skips the first <span class="code">offset<span> results in the response.</td>
</tr>
<tr>
<td>limit</td>
<td>integer</td>
<td>Limits the number of responses to, at most, this number.</td>
</tr>
<tr>
<td>pretty</td>
<td>boolean</td>
<td>If true, pretty prints the response. Default false.</td>
</tr>
<tr>
<td>naked</td>
<td>boolean</td>
<td>If true, returns only the value of the <span class="code">result</span> attribute in the standard response wrapper.</td>
</tr>
<tr>
<td>filter</td>
<td>string</td>
<td>A comma-delimited list of fields to return for each object in the response. Each field may be referenced using JSON notation. See the <a href="#custom-response">Response Customization</a> for more info.</td>
</tr>
</tbody>
</table>
<h4 id="experimental-query-parameters">Experimental query parameters</h4>
<p>Starting with the 2.1.10 release, two new query parameters have been introduced into the jobs api as an experimental feature. The following table lists them for reference</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Values</th>
<th>Purpose</th>
</tr>
</thead>
<tbody>
<tr>
<td>sort</td>
<td>asc, desc </td>
<td>The sort order of the response. <span class="code">asc</span> by default.</td>
</tr>
<tr>
<td>sortBy</td>
<td>string</td>
<td>The field by which to sort the response. Any field present in the full representation of the resource that you are querying is supported. Multiple values are not currently supported.</td>
</tr>
</tbody>
</table>
<h3 id="responses">Responses</h3>
<p>All data is received and returned as a JSON object. The <a title="Live Documentation" href="/live-docs/">Live Docs</a> provide a description of all the retrievable objects.</p>
<h4 id="response-details">Response Details</h4>
<pre class="highlight json"><code><span class="p">{</span><span class="w">
</span><span class="nt">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"error"</span><span class="p">,</span><span class="w">
</span><span class="nt">"message"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Permission denied. You do not have permission to view this system"</span><span class="p">,</span><span class="w">
</span><span class="nt">"version"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2.1.10-r8228"</span><span class="p">,</span><span class="w">
</span><span class="nt">"result"</span><span class="p">:</span><span class="w"> </span><span class="p">{}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
<p>Apart from the response code, all responses from Agave are in the form of a json object. The object takes the following form.</p>
<table>
<thead>
<tr>
<th>Key</th>
<th>Value Type</th>
<th>Value Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>status</td>
<td>string</td>
<td>“success” if the call succeeded or “error” indicating that the call failed.</td>
</tr>
<tr>
<td>message</td>
<td>string</td>
<td>A short description of the cause of the error. </td>
</tr>
<tr>
<td>result</td>
<td>object, array</td>
<td>The JSON response object or array</td>
</tr>
<tr>
<td>version</td>
<td>string</td>
<td>The current full release version of Agave. Ex “2.2.0-r8228”</td>
</tr>
</tbody>
</table>
<p>Here, for example, is the response that occurs when trying to fetch information for system to which you do not have access:</p>
<h4 id="naked-responses">Naked Responses</h4>
<p>In situations where you do not care to parse the wrapper for the raw response data, you may request a <em>naked</em> response from the API by adding <code class="prettyprint">naked=true</code> in to the request URL. This will return just the value of the <code class="prettyprint">result</code> attribute in the response wrapper.</p>
<h3 id="formatting">Formatting</h3>
<p>By default, all responses are serialized JSON. To receive pre-formatted JSON, add <code class="prettyprint">pretty=true</code> to any query string.</p>
<h3 id="pagination">Pagination</h3>
<blockquote>
<p>Pagination using <code class="prettyprint">limit</code> and <code class="prettyprint">offset</code> query parameters.</p>
</blockquote>
<pre class="highlight shell"><code>curl -sk -H <span class="se">\</span>
<span class="s2">"Authorization: Bearer </span><span class="k">${</span><span class="nv">API_KEY</span><span class="k">}</span><span class="s2">"</span> <span class="se">\</span>
<span class="s2">"https://public.tenants.agaveapi.co/jobs/v2/?offset=50&limit=25"</span>
</code></pre>
<pre class="highlight plaintext"><code>jobs-list -o 50 -l 25
</code></pre>
<p>All resource collections support a way of paging the dataset, taking an <code class="prettyprint">offset</code> and <code class="prettyprint">limit</code> as query parameters:</p>
<p>Note that offset numbering is zero-based and that omitting the offset parameter will return the first X elements. By default, all search and listing responses from the Science APIs are paginated in groups of 250 objects. The lone exception being the Files API which will return all results by default.</p>
<p>Check the documentation for the specific endpoint to see specific information.</p>
<aside class="danger">Default pagination size is a tenant-specific configuration value and may vary from tenant to tenant. Check with your admin for the default pagination size configured for your tenant.</aside>
<h3 id="timestamps">Timestamps</h3>
<p>Timestamps are returned in <a href="http://en.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a> format offset for Central Standard Time (-05:00) <code class="prettyprint">YYYY-MM-DDTHH:MM:SSZ-05:00</code>.</p>
<h3 id="cors">CORS</h3>
<p>Many modern applications choose to implement client-server communication exclusively in Javascript. For this reason, Agave provides <a href="http://en.wikipedia.org/wiki/Cross-origin_resource_sharing" title="CORS" target="_blank">cross-origin resource sharing (CORS)</a> support so AJAX requests from a web browser are not constrained by cross-origin requests and can safely make GET, PUT, POST, and DELETE requests to the API.</p>
<h3 id="hypermedia">Hypermedia</h3>
<pre class="highlight plaintext"><code>{
"associationIds": [],
"created": "2013-11-16T11:25:38.900-06:00",
"internalUsername": null,
"lastUpdated": "2013-11-16T11:25:38.900-06:00",
"name": "color",
"owner": "nryan",
"uuid": "0001384622738900-5056a550b8-0001-012",
"value": "red",
"_links": {
"self": {
"href": "https://public.tenants.agaveapi.co/meta/v2/data/0001384622738900-5056a550b8-0001-012"
},
"owner": {
"href": "https://public.tenants.agaveapi.co/profiles/v2/nryan"
}
}
}
</code></pre>
<p>Agave strives to be a fully descriptive hypermedia API. Given any endpoint, you should be able to walk the API through the links provided in the <code class="prettyprint">_links</code> object in each resource representation. The following user metadata object contains two referenced objects. The first, <code class="prettyprint">self</code> is common to all objects, and contains the URL of that object. The second, <code class="prettyprint">owner</code> contains the URL to the profile of the user who created the object.</p>
<h3 id="customizing-responses">Customizing Responses</h3>
<blockquote>
<p>Returns the user id, name, and email for the authenticated user </p>
</blockquote>
<pre class="highlight shell"><code>curl -sk -H <span class="se">\</span>
<span class="s2">"Authorization: Bearer </span><span class="k">${</span><span class="nv">API_KEY</span><span class="k">}</span><span class="s2">"</span> <span class="se">\</span>
<span class="s2">"https://public.tenants.agaveapi.co/profiles/v2/me?filter=username,email
</span></code></pre>
<pre class="highlight plaintext"><code>profiles-list -v --filter=username,email me
</code></pre>
<blockquote>
<p>The response would look something like the following: </p>
</blockquote>
<pre class="highlight json"><code><span class="p">{</span><span class="w">
</span><span class="nt">"username"</span><span class="p">:</span><span class="w"> </span><span class="s2">"nryan"</span><span class="p">,</span><span class="w">
</span><span class="nt">"email"</span><span class="p">:</span><span class="w"> </span><span class="s2">"nryan@rangers.mlb.com"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
<blockquote>
<p>Returns the name, status, app id, and the url to the archived job output for every user job </p>
</blockquote>
<pre class="highlight shell"><code>curl -sk -H <span class="se">\</span>
<span class="s2">"Authorization: Bearer </span><span class="k">${</span><span class="nv">API_KEY</span><span class="k">}</span><span class="s2">"</span> <span class="se">\</span>
<span class="s2">"https://public.tenants.agaveapi.co/jobs/v2/?limit=2&filter=name,status,appId,_links.archiveData.href
</span></code></pre>
<pre class="highlight plaintext"><code>jobs-list -v --limit=2 --filter=name,status,appId,_links.archiveData
</code></pre>
<blockquote>
<p>The response would look something like the following: </p>
</blockquote>
<pre class="highlight json"><code><span class="p">[</span><span class="w">
</span><span class="p">{</span><span class="w">
</span><span class="nt">"name"</span><span class="w"> </span><span class="p">:</span><span class="w"> </span><span class="s2">"demo-pyplot-demo-advanced test-1414139896"</span><span class="p">,</span><span class="w">
</span><span class="nt">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"FINISHED"</span><span class="p">,</span><span class="w">
</span><span class="nt">"appId"</span><span class="w"> </span><span class="p">:</span><span class="w"> </span><span class="s2">"demo-pyplot-demo-advanced-0.1.0"</span><span class="p">,</span><span class="w">
</span><span class="nt">"_links"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nt">"archiveData"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nt">"href"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://agave.iplantc.org/jobs/v2/0001414144065563-5056a550b8-0001-007/outputs/listings"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="p">{</span><span class="w">
</span><span class="nt">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"demo-pyplot-demo-advanced test-1414270831"</span><span class="p">,</span><span class="w">
</span><span class="nt">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"FINISHED"</span><span class="p">,</span><span class="w">
</span><span class="nt">"appId"</span><span class="w"> </span><span class="p">:</span><span class="w"> </span><span class="s2">"demo-pyplot-demo-advanced-0.1.0"</span><span class="p">,</span><span class="w">
</span><span class="nt">"_links"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nt">"archiveData"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nt">"href"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://agave.iplantc.org/jobs/v2/3259859908028273126-242ac115-0001-007/outputs/listings"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">]</span><span class="w">
</span></code></pre>
<blockquote>
<p>Returns the system id, type, whether it is your default system, and the hostname from the system’s storage config </p>
</blockquote>
<pre class="highlight shell"><code>/systems/v2/?filter<span class="o">=</span>id,type,default,storage.host
</code></pre>
<pre class="highlight plaintext"><code>systems-list -v --limit=2 --filter=id,type,default,storage.host
</code></pre>
<blockquote>
<p>The response would look something like the following: </p>
</blockquote>
<pre class="highlight json"><code><span class="p">[</span><span class="w">
</span><span class="p">{</span><span class="w">
</span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"data.agaveapi.co"</span><span class="p">,</span><span class="w">
</span><span class="nt">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"STORAGE"</span><span class="p">,</span><span class="w">
</span><span class="nt">"default"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
</span><span class="nt">"storage"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nt">"host"</span><span class="p">:</span><span class="w"> </span><span class="s2">"dtn01.prod.agaveapi.co"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="p">{</span><span class="w">
</span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"docker.tacc.utexas.edu"</span><span class="p">,</span><span class="w">
</span><span class="nt">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"EXECUTION"</span><span class="p">,</span><span class="w">
</span><span class="nt">"default"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
</span><span class="nt">"storage"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nt">"host"</span><span class="p">:</span><span class="w"> </span><span class="s2">"129.114.6.50"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">]</span><span class="w">
</span></code></pre>
<p>In many situations, Agave may return back too much or too little information in the response to a query. For example, when searching jobs, the <code class="prettyprint">inputs</code> and <code class="prettyprint">parameters</code> fields are not included in the default summary response objects. You can customize the responses you receive from all the Science APIs using the <code class="prettyprint">filter</code> query parameter. </p>
<p>The <code class="prettyprint">filter</code> query parameter takes a comma-delimited list of fields to return for each object in the response. Each field may be referenced using JSON notation similar to the search syntax (minus the <code class="prettyprint">.[operation]</code> suffix. The examples to the right show sample requests and responses. </p>
<h3 id="status-codes">Status Codes</h3>
<p>The API uses the following response status codes, as defined in the <a href="https://www.ietf.org/rfc/rfc2616.txt" target="_blank">RFC 2616</a> on successful and unsuccessful requests.</p>
<h4 id="success-codes">Success Codes</h4>
<table><thead>
<tr>
<th>Response Code</th>
<th>Meaning</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr>
<td>200</td>
<td>Success</td>
<td>The request succeeded. Life is good.</td>
</tr>
<tr>
<td>201</td>
<td>Created</td>
<td>The request succeeded and a new resource was created. Only applicable on PUT and POST actions.</td>
</tr>
<tr>
<td>202</td>
<td>Accepted</td>
<td>The request has been accepted for processing, but the processing has not been completed. Common for all async actions such as job submissions, file transfers, etc.</td>
</tr>
<tr>
<td>206</td>
<td>Partial Content</td>
<td>The server has fulfilled the partial GET request for the resource. This will always be the return status of a request using a <code class="prettyprint">Range</code> header.</td>
</tr>
<tr>
<td>301</td>
<td>Moved Permanently</td>
<td>The requested resource has been assigned a new permanent URI. You should follow the <code class="prettyprint">Location</code> header, repeating the request.</td>
</tr>
<tr>
<td>304</td>
<td>Not Modified</td>
<td>You requested an action that succeeded, but did not modify the resource. Sound, fury, that whole thing.</td>
</tr>
</tbody></table>
<h4 id="error-codes">Error Codes</h4>
<table><thead>
<tr>
<th>Response Code</th>
<th>Meaning</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr>
<td>400</td>
<td>Bad Request</td>
<td>Your request was invalid</td>
</tr>
<tr>
<td>401</td>
<td>Unauthorized</td>
<td>Authentication required, but not provided</td>
</tr>
<tr>
<td>403</td>
<td>Forbidden</td>
<td>You do not have permission to access the given resource</td>
</tr>
<tr>
<td>404</td>
<td>Not Found</td>
<td>No resource was found at the given URL</td>
</tr>
<tr>
<td>405</td>
<td>Method Not Allowed</td>
<td>You tried to access a resource with an invalid method</td>
</tr>
<tr>
<td>406</td>
<td>Not Acceptable</td>
<td>You requested a response format that isn’t supported</td>
</tr>
<tr>
<td>410</td>
<td>Gone</td>
<td>The resource you requested has been removed and/or deleted</td>
</tr>
<tr>
<td>429</td>
<td>Too Many Requests</td>
<td>Curb your enthusiasm. You’re going way to fast.</td>
</tr>
<tr>
<td>500</td>
<td>Internal Server Error</td>
<td>It’s not you, it’s us. We had a problem processing your request. Try again later.</td>
</tr>
<tr>
<td>503</td>
<td>Service Unavailable</td>
<td>The service is temporarially unavailable. Please try again later.</td>
</tr>
<tr>
<td>504</td>
<td>Gateway Timeout</td>
<td>The service, while acting as a gateway or proxy, did not receive a timely response from the upstream server.</td>
</tr>
</tbody></table>
<h1 id="sdk">SDK</h1>
<h1 id="web-api">Web API</h1>
<p>The Agave Science APIs power the Science-as-a-Service functionality of the Agave Platform. These web APIs allow you to manage all aspects of your code, collaborations, data, and your digital lab. </p>
<p>The Science APIs follow basic REST concepts and use JSON to exchange data. Formal documentation of all endpoints is available in <a href="http://swagger.io/">Swagger 2.0</a> format. You may access the Swagger definitions directly in <a href="live-docs/agave.json">JSON</a> and <a href="live-docs/agave.yml">YAML</a> formats.</p>
<aside class="info">You can read more about some of the <a href="#conventions">Conventions</a> we use in the introduction.</aside>
<h2 id="interactive-api-explorer">Interactive API Explorer</h2>
<p>Often it is easier to explore a new API using an interactive tool rather than writing code. We provide our <a href="live-docs/">Live Docs</a>, an interactive API browser based on the Swagger UI project, to help you kick the tires on the API and get example requests and responses to help with your onboarding efforts. </p>
<p style="text-align:center;margin-top:45px;"><a style="padding:12px 15px;line-height: 30px; outline: 0;background: #00a7b8; color: #ffffff; text-decoration:none!important;" href="live-docs/">Visit Agave Live Docs</a></p>
<h1 id="guides">Guides</h1>
<p>The Agave REST APIs enable applications to create and manage digital laboratories that spans campuses, the cloud, and multiple data centers using a cohesive set of web-friendly interfaces.</p>
<h2 id="authorization">Authorization</h2>
<pre class="highlight json"><code><span class="w"> </span><span class="err">/$$$$$$</span><span class="w"> </span><span class="err">/$$$$$$</span><span class="w"> </span><span class="err">/$$</span><span class="w"> </span><span class="err">/$$</span><span class="w">
</span><span class="err">/$$__</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">/$$__</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w">
</span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">\</span><span class="w"> </span><span class="err">$$|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">\</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">/$$</span><span class="w"> </span><span class="err">/$$</span><span class="w"> </span><span class="err">/$$$$$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$$$$$$</span><span class="w">
</span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$|</span><span class="w"> </span><span class="err">$$$$$$$$|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$|_</span><span class="w"> </span><span class="err">$$_/</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$__</span><span class="w"> </span><span class="err">$$</span><span class="w">
</span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$|</span><span class="w"> </span><span class="err">$$__</span><span class="w"> </span><span class="err">$$|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">\</span><span class="w"> </span><span class="err">$$</span><span class="w">
</span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">/$$|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w">
</span><span class="err">|</span><span class="w"> </span><span class="err">$$$$$$/|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$|</span><span class="w"> </span><span class="err">$$$$$$/</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$$$/|</span><span class="w"> </span><span class="err">$$</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">$$</span><span class="w">
</span><span class="err">\______/</span><span class="w"> </span><span class="err">|__/</span><span class="w"> </span><span class="err">|__/</span><span class="w"> </span><span class="err">\______/</span><span class="w"> </span><span class="err">\___/</span><span class="w"> </span><span class="err">|__/</span><span class="w"> </span><span class="err">|__/</span><span class="w">
</span></code></pre>
<p>Most requests to the Agave REST APIs require authorization; that is, the user must have granted permission for an application to access the requested data. To prove that the user has granted permission, the request header sent by the application must include a valid access token.</p>
<p>Before you can begin the authorization process, you will need to <a title="Client Registration" href="#client-registration/">register your client application</a>. That will give you a unique client key and secret key to use in the authorization flows.</p>
<h3 id="supported-authorization-flows">Supported Authorization Flows</h3>
<p>The Agave REST APIs currently supports four authorization flows:</p>
<ol>
<li>The <a href="#authorization-code">Authorization Code</a> flow first gets a code then exchanges it for an access token and a refresh token. Since the exchange uses your client secret key, you should make that request server-side to keep the integrity of the key. An advantage of this flow is that you can use refresh tokens to extend the validity of the access token.</li>
<li>The <a href="#implicit-grant">Implicit Grant</a> flow is carried out client-side and does not involve secret keys. The access tokens that are issued are short-lived and there are no refresh tokens to extend them when they expire.</li>
<li><a href="#resource-owner-password-credentials">Resource Owner Password Credentials</a> flow is suitable for native and mobile applications as well as web services, this flow allows client applications to obtain an access token for a user by directly providing the user credentials in an authentication request. This flow exposes the user’s credentials to the client application and is primarily used in situations where the client application is highly trusted such as the command line.</li>
<li>The <a href="#client-credentials">Client Credentials</a> flow enables users to interact with their own protected resources directly without requiring browser interaction. This is a critical addition for use at the command line, in scripts, and in offline programs. This flow assumes the person registering the client application and the user on whose behalf requests are made be the same person.</li>
</ol>
<table>
<thead>
<tr>
<th>Flow</th>
<th>Can fetch a user’s data by requesting access?</th>
<th>Uses secret key? (key exchange must happen server-side!)</th>
<th>Access token can be refreshed?</th>
</tr>
</thead>
<tbody>
<tr>
<td>Authorization Code</td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<td>Implicit Grant</td>
<td>Yes</td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td>Resource Owner Password Credentials</td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<td>Client Credentials</td>
<td>No</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td>Unauthorized</td>
<td>No</td>
<td>No</td>
<td>No</td>
</tr>
</tbody>
</table>
<aside class="notice"><b>Additional Help:</b> You can read our <a href="/tools/web-application-tutorial" title="Agave Web Application Tutorial">step-by-step tutorial</a> where we explain how to run an example application using these flows. In addition, we have a list of <a href="/tools/" title="Tools">handy wrappers and tools</a> for your language of choice.</aside>
<h3 id="authorization-code">Authorization Code</h3>
<p>The method is suitable for long-running applications in which the user logs in once and the access token can be refreshed. Since the token exchange involves sending your secret key, this should happen on a secure location, like a backend service, not from a client like a browser or mobile apps. This flow is described in <a href="http://tools.ietf.org/html/rfc6749#section-4.4" title="RFC-6749">RFC-6749</a>. This flow is also the authorization flow used in our REST API Tutorial.</p>
<p>
<img src="images/2014/09/Authorization-Code-Flow.png" alt="Authorization Code Flow Diagram" style="height: auto;"/>
</p>
<h4 id="1-your-application-requests-authorization">1. Your application requests authorization</h4>
<blockquote>
<p>A typical request will look something like this</p>
</blockquote>
<pre class="highlight http"><code><span class="err">https://public.tenants.agaveapi.co/authorize/?client_id=gTgp...SV8a&response_type=code&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback&scope=PRODUCTION&state=866
</span></code></pre>
<p>The authorization process starts with your application sending a request to the Agave authorization service. (The reason your application sends this request can vary: it may be a step in the initialization of your application or in response to some user action, like a button click.) The request is sent to the /authorize endpoint of the Authorization service:</p>
<p>The request will include parameters in the query string:</p>
<table>
<thead>
<tr>
<th>Request body parameter</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>response_type</td>
<td><i>Required</i>. As defined in the OAuth 2.0 specification, this field must contain the value “code”.</td>
</tr>
<tr>
<td>client_id</td>
<td><i>Required</i>. The application’s client ID, obtained when the client application was registered with Agave (see <a href="/documentation/tutorials/client-registration/">Client Registration</a>).</td>
</tr>
<tr>
<td>redirect_uri</td>
<td><i>Required</i>. The URI to redirect to after the user grants/denies permission. This URI needs to have been entered in the Redirect URI whitelist that you specified when you registered your application. The value of <code>redirect_uri</code> here must exactly match one of the values you entered when you registered your application, including upper/lowercase, terminating slashes, etc.</td>
</tr>
<tr>
<td>scope</td>
<td><i>Optional</i>. A space-separated list of scopes. Currently only PRODUCTION is supported.</td>
</tr>
<tr>
<td>state</td>
<td><i>Optional,</i> but strongly recommended. The state can be useful for correlating requests and responses. Because your redirect_uri can be guessed, using a state value can increase your assurance that an incoming connection is the result of an authentication request. If you generate a random string or encode the hash of some client state (e.g., a cookie) in this state variable, you can validate the response to additionally ensure that the request and response originated in the same browser. This provides protection against attacks such as cross-site request forgery. See <a href="http://tools.ietf.org/html/rfc6749#section-4.4" title="RFC-6749">RFC-6749</a>. </td>
</tr>
</tbody>
</table>
<h4 id="2-the-user-is-asked-to-authorize-access-within-the-scopes">2. The user is asked to authorize access within the scopes</h4>
<p>The Agave Authorization service presents details of the scopes for which access is being sought. If the user is not logged in, they are prompted to do so using their API username and password.</p>
<p>When the user is logged in, they are asked to authorize access to the actions and services defined in the scopes.</p>
<h4 id="3-the-user-is-redirected-back-to-your-specified-uri">3. The user is redirected back to your specified URI</h4>
<blockquote>
<p>Let’s assume you provided the following callback URL.</p>
</blockquote>
<pre class="highlight http"><code><span class="err">https://example.com/callback
</span></code></pre>
<p>After the user accepts (or denies) your request, the Agave Authorization service redirects back to the redirect_uri. If the user has accepted your request, the response query string contains a <code class="prettyprint">code</code> parameter with the access code you will use in the next step to retrieve an access token.</p>
<blockquote>
<p>Sample success redirect back from the server</p>
</blockquote>
<pre class="highlight http"><code><span class="err">https://example.com/callback?code=Pq3S..M4sY&state=866
</span></code></pre>
<table>
<thead>
<tr>
<th>Query parameter </th>
<th>Value </th>
</tr>
</thead>
<tbody>
<tr>
<td>access_token </td>
<td>An access token that can be provided in subsequent calls, for example to <a href="https://public.agaveapi.co/profiles/v2/me?pretty=true">Agave Profiles API</a>. </td>
</tr>
<tr>
<td>token_type </td>
<td>Value: “bearer” </td>
</tr>
<tr>
<td>expires_in </td>
<td>The time period (in seconds) for which the access token is valid. </td>
</tr>
<tr>
<td>state </td>
<td>The value of the <code>state</code> parameter supplied in the request. </td>
</tr>
</tbody>
</table>
<p>If the user has denied access, there will be no access token and the final URL will have a query string containing the following parameters:</p>
<pre class="highlight plaintext"><code># Sample denial redirect back from the server
https://example.com/callback?error=access_denied&state=867
</code></pre>
<table>
<thead>
<tr>
<th>Query parameter
</th>
<th>Value
</th>
</tr>
</thead>
<tbody>
<tr>
<td>error
</td>
<td>The reason authorization failed, for example: “access_denied” </td>
</tr>
<tr>
<td>state
</td>
<td>The value of the state parameter supplied in the request. </td>
</tr>
</tbody>
</table>
<h4 id="4-your-application-requests-refresh-and-access-tokens">4. Your application requests refresh and access tokens</h4>
<pre class="highlight http"><code><span class="err">POST https://public.tenants.agaveapi.co/token
</span></code></pre>
<p>When the authorization code has been received, you will need to exchange it with an access token by making a POST request to the Agave Authorization service, this time to its <code class="prettyprint">/token</code> endpoint. The body of this POST request must contain the following parameters:</p>
<table>
<thead>
<tr>
<th>Request body parameter</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>grant_type</td>
<td><i>Required</i>. As defined in the OAuth 2.0 specification, this field must contain the value “authorization_code”.</td>
</tr>
<tr>
<td>code</td>
<td><i>Required</i>. The authorization code returned from the initial request to the Account’s <code>/authorize</code> endpoint. <br/></td>
</tr>
<tr>
<td>redirect_uri</td>
<td><i>Required</i>. This parameter is used for validation only (there is no actual redirection). The value of this parameter must <i>exactly</i> match the value of <code>redirect_uri</code> supplied when requesting the authorization code.</td>
</tr>
<tr>
<td>client_id</td>
<td><i>Required</i>. The application’s client ID, obtained when the client application was registered with Agave (see <a href="/documentation/tutorials/client-registration/">Client Registration</a>).</td>
</tr>
<tr>
<td>client_secret</td>
<td><i>Required</i>. The application’s client secret key, obtained when the client application was registered with Agave (see <a href="/documentation/tutorials/client-registration/">Client Registration</a>).</td>
</tr>
</tbody>
</table>
<h4 id="5-the-tokens-are-returned-to-your-application">5. The tokens are returned to your application</h4>
<pre class="highlight json"><code><span class="err">#</span><span class="w"> </span><span class="err">An</span><span class="w"> </span><span class="err">example</span><span class="w"> </span><span class="err">cURL</span><span class="w"> </span><span class="err">request</span><span class="w">
</span><span class="err">curl</span><span class="w"> </span><span class="err">-X</span><span class="w"> </span><span class="err">POST</span><span class="w"> </span><span class="err">-d</span><span class="w"> </span><span class="s2">"grant_type= authorization_code"</span><span class="w">
</span><span class="err">-d</span><span class="w"> </span><span class="s2">"code=Pq3S..M4sY"</span><span class="w">
</span><span class="err">-d</span><span class="w"> </span><span class="s2">"client_id=gTgp...SV8a"</span><span class="w">
</span><span class="err">-d</span><span class="w"> </span><span class="s2">"client_secret=hZ_z3f...BOD6"</span><span class="w">
</span><span class="err">-d</span><span class="w"> </span><span class="s2">"redirect_uri=https%3A%2F%2Fwww.foo.com%2Fauth"</span><span class="w">
</span><span class="err">https://public.tenants.agaveapi.co/token</span><span class="w">
</span></code></pre>
<blockquote>
<p>The response would look something like this:</p>
</blockquote>
<pre class="highlight json"><code><span class="p">{</span><span class="w">
</span><span class="nt">"access_token"</span><span class="p">:</span><span class="w"> </span><span class="s2">"a742...12d2"</span><span class="p">,</span><span class="w">
</span><span class="nt">"expires_in"</span><span class="p">:</span><span class="w"> </span><span class="mi">14400</span><span class="p">,</span><span class="w">
</span><span class="nt">"refresh_token"</span><span class="p">:</span><span class="w"> </span><span class="s2">"d77c...Sacf"</span><span class="p">,</span><span class="w">
</span><span class="nt">"token_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"bearer"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
<p>On success, the response from the Agave Authorization service has the status code 200 OK in the response header, and a JSON object with the fields in the following table in the response body:</p>
<table>
<thead>
<tr>
<th>Key
</th>
<th>Value type</th>
<th>Value description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>access_token
</td>
<td>string</td>
<td>An access token that can be provided in subsequent calls, for example to Agave REST APIs.
</td>
</tr>
<tr>
<td>token_type
</td>
<td>string</td>
<td>How the access token may be used: always “Bearer”.
</td>
</tr>
<tr>
<td>expires_in
</td>
<td>int</td>
<td>The time period (in seconds) for which the access token is valid. (Maximum 14400 seconds, or 4 hours.)
</td>
</tr>
<tr>
<td>refresh_token</td>
<td>string</td>
<td>A token that can be sent to the Spotify Accounts service in place of an authorization code. (When the access code expires, send a POST request to the Accounts service <code>/token</code> endpoint, but use this code in place of an authorization code. A new access token will be returned. A new refresh token might be returned too.) </td>
</tr>
</tbody>
</table>
<h4 id="6-use-the-access-token-to-access-the-agave-rest-apis">6. Use the access token to access the Agave REST APIs</h4>
<blockquote>
<p>Make a call to the API</p>
</blockquote>
<pre class="highlight http"><code><span class="err">curl -H "Authorization: Bearer a742...12d2"
https://public.tenants.agaveapi.co/profiles/v2/me?pretty=true&naked=true
</span></code></pre>
<blockquote>
<p>The response would look something like this:</p>
</blockquote>
<pre class="highlight json"><code><span class="p">{</span><span class="w">
</span><span class="nt">"create_time"</span><span class="p">:</span><span class="w"> </span><span class="s2">"20140905072223Z"</span><span class="p">,</span><span class="w">
</span><span class="nt">"email"</span><span class="p">:</span><span class="w"> </span><span class="s2">"rjohnson@mlb.com"</span><span class="p">,</span><span class="w">
</span><span class="nt">"first_name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Randy"</span><span class="p">,</span><span class="w">
</span><span class="nt">"full_name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Randy Johnson"</span><span class="p">,</span><span class="w">
</span><span class="nt">"last_name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Johnson"</span><span class="p">,</span><span class="w">
</span><span class="nt">"mobile_phone"</span><span class="p">:</span><span class="w"> </span><span class="s2">"(123) 456-7890"</span><span class="p">,</span><span class="w">
</span><span class="nt">"phone"</span><span class="p">:</span><span class="w"> </span><span class="s2">"(123) 456-7890"</span><span class="p">,</span><span class="w">
</span><span class="nt">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Active"</span><span class="p">,</span><span class="w">
</span><span class="nt">"uid"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
</span><span class="nt">"username"</span><span class="p">:</span><span class="w"> </span><span class="s2">"rjohnson"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
<p>Once you have a valid access token, you can include it in <code class="prettyprint">Authorization</code> header for all subsequent requests to APIs in the Platform.</p>
<h4 id="7-requesting-access-token-from-refresh-token">7. Requesting access token from refresh token</h4>
<pre class="highlight http"><code><span class="err">curl -sku "Authorization: Basic Qt3c...Rm1y="
-d grant_type=refresh_token
-d refresh_token=d77c...Sacf
https://public.tenants.agaveapi.co/token
</span></code></pre>
<blockquote>
<p>The response would look something like this.</p>
</blockquote>
<pre class="highlight json"><code><span class="p">{</span><span class="w">
</span><span class="nt">"access_token"</span><span class="p">:</span><span class="w"> </span><span class="s2">"61e6...Mc96"</span><span class="p">,</span><span class="w">
</span><span class="nt">"expires_in"</span><span class="p">:</span><span class="w"> </span><span class="mi">14400</span><span class="p">,</span><span class="w">