-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswagger.yaml
13690 lines (12877 loc) · 518 KB
/
swagger.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
info:
termsOfService: 'https://www.atlassian.com/legal/customer-agreement'
version: '2.0'
title: Bitbucket API
description: 'Code against the Bitbucket API to automate simple tasks, embed Bitbucket data into your own site, build mobile or desktop apps, or even add custom UI add-ons into Bitbucket itself using the Connect framework.'
contact:
url: 'https://support.atlassian.com/bitbucket-cloud/'
name: Bitbucket Support
email: [email protected]
x-radar-pages:
- content: |
WARNING !!!!!!!!!!!!!!!
Note that this was edited from https://bitbucket.org/api/swagger.json on 2018-06-29 due to
https://github.com/swagger-api/swagger-codegen/issues/5562
I had to remove everything relating to pipelines
!!!!!!!!!!!!!!!!
# Authentication methods
The purpose of this section is to describe how to authenticate when making API calls using the Bitbucket REST API.
-----
*On this page*
* [Oauth 2](#oauth-2)
* [Making requests](#make-requests)
* [Repository cloning](#repo-clone)
* [Refresh tokens](#refresh-tokens)
* [Scopes](#scopes-bbc)
* [App passwords](#app-pw)
* [Basic auth](#basic-auth)
---
# Bitbucket Cloud OAuth 2.0 <a name="oauth-2"></a>
Our OAuth 2 implementation is merged in with our existing OAuth 1 in
such a way that existing OAuth 1 consumers automatically become
valid OAuth 2 clients. The only thing you need to do is edit your
existing consumer and configure a callback URL.
Once that is in place, you'll have the following 2 URLs:
https://bitbucket.org/site/oauth2/authorize
https://bitbucket.org/site/oauth2/access_token
For obtaining access/bearer tokens, we support all 4 of RFC-6749's grant
flows, plus a custom Bitbucket flow for exchanging JWT tokens for access tokens:
### 1. Authorization Code Grant (4.1)
The full-blown 3-LO flow. Request authorization from the end user by
sending their browser to:
https://bitbucket.org/site/oauth2/authorize?client_id={client_id}&response_type=code
The callback includes the `?code={}` query parameter that you can swap
for an access token:
$ curl -X POST -u "client_id:secret" \
https://bitbucket.org/site/oauth2/access_token \
-d grant_type=authorization_code -d code={code}
### 2. Implicit Grant (4.2)
This flow is useful for browser-based add-ons that operate without server-side backends.
Request the end user for authorization by directing the browser to:
https://bitbucket.org/site/oauth2/authorize?client_id={client_id}&response_type=token
That will redirect to your preconfigured callback URL with a fragment
containing the access token
(`#access_token={token}&token_type=bearer`) where your page's js can
pull it out of the URL.
### 3. Resource Owner Password Credentials Grant (4.3)
Useful if you have the end user's password but you want to use a more
secure end user access token instead. This method will not work when the user has two-step verification enabled.
$ curl -X POST -u "client_id:secret" \
https://bitbucket.org/site/oauth2/access_token -d grant_type=password \
-d username={username} -d password={password}
### 4. Client Credentials Grant (4.4)
Somewhat like our existing "2-LO" flow for OAuth 1. Obtain an access
token that represents not an end user, but the owner of the
client/consumer:
$ curl -X POST -u "client_id:secret" \
https://bitbucket.org/site/oauth2/access_token \
-d grant_type=client_credentials
### 5. Bitbucket Cloud JWT Grant (urn:bitbucket:oauth2:jwt)
If your Atlassian Connect add-on uses JWT authentication, you can swap a
JWT for an OAuth access token. The resulting access token represents the
account for which the add-on is installed.
Make sure you send the JWT token in the Authorization request header
using the "JWT" scheme (case sensitive). Note that this custom scheme
makes this different from HTTP Basic Auth (and so you cannot use "curl
-u").
$ curl -X POST -H "Authorization: JWT {jwt_token}" \
https://bitbucket.org/site/oauth2/access_token \
-d grant_type=urn:bitbucket:oauth2:jwt
## Making Requests <a name="make-requests"></a>
Once you have an access token, as per RFC-6750, you can use it in a request in any of
the following ways (in decreasing order of desirability):
1. Send it in a request header: `Authorization: Bearer {access_token}`
2. Include it in a (application/x-www-form-urlencoded) POST body as `access_token={access_token}`
3. Put it in the query string of a non-POST: `?access_token={access_token}`
## Repository Cloning <a name="repo-clone"></a>
Since add-ons will not be able to upload their own SSH keys to clone
with, access tokens can be used as Basic HTTP Auth credentials to
clone securely over HTTPS. This is much like GitHub, yet slightly
different:
$ git clone https://x-token-auth:{access_token}@bitbucket.org/user/repo.git
The literal string `x-token-auth` as a substitute for username is
required (note the difference with GitHub where the actual token is in
the username field).
## Refresh Tokens <a name="refresh-tokens"></a>
Our access tokens expire in one hour. When this happens you'll get 401
responses.
Most access tokens grant responses (Implicit and JWT excluded). Therefore, you should include a
refresh token that can then be used to generate a new access token,
without the need for end user participation:
$ curl -X POST -u "client_id:secret" \
https://bitbucket.org/site/oauth2/access_token \
-d grant_type=refresh_token -d refresh_token={refresh_token}
# Scopes for the Bitbucket Cloud REST API <a name="scopes-bbc"></a>
Bitbucket's API applies a number of privilege scopes to endpoints. In order to access an endpoint, a request will need to have the necessary scopes.
Scopes are declared in the descriptor as a list of strings, with each string being the name of a unique scope.
A descriptor lacking the `scopes` element is implicitly assumed to require all scopes and as a result, Bitbucket will require end users authorizing/installing the add-on
to explicitly accept all scopes.
Our best practice suggests you add the scopes your add-on needs, but no more than it needs.
Invalid scope strings will cause the descriptor to be rejected and the installation to fail.
Following is the set of all currently available scopes.
### repository
Gives the add-on read access to all the repositories the authorizing user has access to.
Note that this scope does not give access to a repository's pull requests.
* access to the repo's source code
* clone over https
* access the the file browsing API
* download zip archives of the repo's contents
* the ability to view and use the issue tracker on any repo (created issues, comment, vote, etc)
* the ability to view and use the wiki on any repo (create/edit pages)
### repository:write
Gives the add-on write (not admin) access to all the repositories the authorizing user has access to. No distinction is made between public or private repos. This scope implies `repository`, which does not need to be requested separately.
This scope alone does not give access to the pull requests API.
* push access over https
* fork repos
### repository:admin
Gives the add-on admin access to all the repositories the authorizing user has access to. No distinction is made between public or private repos. This scope does not imply `repository` or `repository:write`. It gives access to the admin features of a repo only, not direct access to its contents. Of course it can be (mis)used to grant read access to another user account who can then clone the repo, but repos that need to read of write source code would also request explicit read or write.
This scope comes with access to the following functionality:
* view and manipulate committer mappings
* list and edit deploy keys
* ability to delete the repo
* view and edit repo permissions
* view and edit branch permissions
* import and export the issue tracker
* enable and disable the issue tracker
* list and edit issue tracker version, milestones and components
* enable and disable the wiki
* list and edit default reviewers
* list and edit repo links (Jira/Bamboo/Custom)
* list and edit the repository web hooks
* initiate a repo ownership transfer
### snippet
Gives the add-on read access to all the snippets the authorizing user has access to.
No distinction is made between public and private snippets (public snippets are accessible without any form of authentication).
* view any snippet
* create snippet comments
### snippet:write
Gives the add-on write access to all the snippets the authorizing user can edit.
No distinction is made between public and private snippets (public snippets are accessible without any form of authentication).
This implies the Snippet Read scope which does not need to be requested separately.
* edit snippets
* delete snippets
### issue
Ability to interact with issue trackers the way non-repo members can.
This scope does not imply any other scopes and does not give implicit access to the repository the issue is attached to.
* view, list and search issues
* create new issues
* comment on issues
* watch issues
* vote for issues
### issue:write
This implies `issue`, but adds the ability to transition and delete issues.
This scope does not imply any other scopes and does not give implicit access to the repository the issue is attached to.
* transition issues
* delete issues
### wiki
Gives access to wikis. No distinction is made between read and write as wikis are always editable by anyone.
This scope does not imply any other scopes and does not give implicit access to the repository the wiki is attached to.
* view wikis
* create pages
* edit pages
* push to wikis
* clone wikis
### pullrequest
Gives the add-on read access to pull requests.
This scope implies `repository`, giving read access to the pull request's destination repository.
* see and list pull requests
* create and resolve tasks
### pullrequest:write
Implies `pullrequest` but adds the ability to create, merge and decline pull requests.
This scope implies `repository:write`, giving write access to the pull request's destination repository. This is necessary to facilitate merging.
* merge pull requests
* decline pull requests
* create pull requests
* comment on pull requests
* approve pull requests
### email
Ability to see the user's primary email address. This should make it easier to use Bitbucket Cloud as a login provider to add-ons or external applications.
### account
Ability to see all the user's account information. Note that this does not include any ability to mutate any of the data.
* see all email addresses
* language
* location
* website
* full name
* SSH keys
* user groups
### account:write
Ability to change properties on the user's account.
* delete the authorizing user's account
* manage the user's groups
* manupilate a user's email addresses
* change username, display name and avatar
### team
The ability to find out what teams the current user is part of. This is covered by the teams endpoint.
* information about all the groups and teams I am a member or admin of
### team:write
Implies `team`, but adds the ability to manage the teams that the authorizing user is an admin on.
* manage team permissions
### webhook
Gives access to webhooks. This scope is required for any webhook
related operation.
This scope gives read access to existing webhook subscriptions on all
resources you can access, without needing further scopes. This means that
a client can list all existing webhook subscriptions on repository
`foo/bar` (assuming the principal user has access to this repo). The
additional `repository` scope is not required for this.
Likewise, existing webhook subscriptions for a repo's issue tracker can be
retrieved without holding the `issue` scope. All that is required is the
`webhook` scope.
However, to create a webhook for `issue:created`, the client will need to
have both the `webhook` as well as `issue` scope.
* list webhook subscriptions on any accessible repository, user, team, or snippet
* create/update/delete webhook subscriptions
# App passwords <a name="app-pw"></a>
App passwords allow two-step verification users to make API calls to their Bitbucket account through apps such as Sourcetree.
Some important points about app passwords:
* You cannot view an app password or adjust permissions after you create the app password. Because app passwords are encrypted on our database and cannot be viewed by anyone. They are essentially designed to be disposable. If you need to change the scopes or lost the password just create a new one.
* You cannot use them to log into your Bitbucket account.
* You cannot use app passwords to manage team actions.
App passwords are tied to an individual account's credentials and should not be shared. If you're sharing your app password you're essentially giving direct, authenticated, access to everything that password has been scoped to do with the Bitbucket API's.
* You can use them for API call authentication, even if you don't have two-step verification enabled.
* You can set permission scopes (specific access rights) for each app password.
### Create an app password
To create an app password:
1. Select **Avatar > Bitbucket settings**.
2. Click **App passwords** in the Access management section.
3. Click **Create app password**.
4. Give the app password a name related to the application that will use the password.
5. Select the specific access and permissions you want this application password to have.
6. Copy the generated password and either record or paste it into the application you want to give access. The password is only displayed this one time.
That's all there is to creating an app password. See your applications documentation for how to apply the app password for a specific application.
## Basic auth <a name="basic-auth"></a>
Basic HTTP Authentication as per [RFC-2617](https://tools.ietf.org/html/rfc2617) (Digest not supported). Note that Basic Auth with username and password as credentials is only available on accounts that have 2-factor-auth / 2-step-verification disabled. If you use 2fa, you should authenticate using OAuth2 instead.
title: Authentication methods
description: How to authenticate API actions
key: authentication
icon: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOTcuNjQ3MyAxODYuODEzOCI+CiAgPGRlZnM+CiAgICA8c3R5bGU+CiAgICAgIC5jbHMtMSB7CiAgICAgICAgaXNvbGF0aW9uOiBpc29sYXRlOwogICAgICB9CgogICAgICAuY2xzLTIgewogICAgICAgIGZpbGw6ICNkZTM1MGI7CiAgICAgIH0KCiAgICAgIC5jbHMtMyB7CiAgICAgICAgZmlsbDogI2ZmNTYzMDsKICAgIC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c3M9ImNscy0xMCIgZD0iTTgxLjc5NzUsMTAwLjMxYTMuOTQzOSwzLjk0MzksMCwwLDAtMy45NDQzLTMuOTQ0M0g0MS4wNDE3YTMuOTQ0MywzLjk0NDMsMCwwLDAsMCw3Ljg4ODdINzcuODUzMkEzLjk0MzksMy45NDM5LDAsMCwwLDgxLjc5NzUsMTAwLjMxWiIvPgogICAgICAgIDxwYXRoIGlkPSJfUGF0aF8yIiBkYXRhLW5hbWU9IiZsdDtQYXRoJmd0OyIgY2xhc3M9ImNscy0xMSIgZD0iTTQxLjA0MTYsMTA0LjI1MzlIOTYuODUzMmEzLjk0NDMsMy45NDQzLDAsMCwwLDAtNy44ODg3SDQxLjA0MTZhMy45NDQzLDMuOTQ0MywwLDAsMCwwLDcuODg4N1oiLz4KICAgICAgICA8cGF0aCBjbGFzcz0iY2xzLTEwIiBkPSJNODEuNzk3NSwxMDAuMzFhMy45NDM5LDMuOTQzOSwwLDAsMC0zLjk0NDMtMy45NDQzSDQxLjA0MTdhMy45NDQzLDMuOTQ0MywwLDAsMCwwLDcuODg4N0g3Ny44NTMyQTMuOTQzOSwzLjk0MzksMCwwLDAsODEuNzk3NSwxMDAuMzFaIi8+CiAgICAgICAgPHBhdGggY2xhc3M9ImNscy0xMCIgZD0iTTIyLjQ5MzIsMTIyLjgwMjlBMjIuNDkyOSwyMi40OTI5LDAsMSwxLDQ0Ljk4NTgsMTAwLjMxLDIyLjUxODUsMjIuNTE4NSwwLDAsMSwyMi40OTMyLDEyMi44MDI5Wm0wLTM3LjA5NzJBMTQuNjA0MiwxNC42MDQyLDAsMSwwLDM3LjA5NzIsMTAwLjMxLDE0LjYyMDcsMTQuNjIwNywwLDAsMCwyMi40OTMyLDg1LjcwNTdaIi8+CiAgICAgIDwvZz4KICAgIDwvZz4KICA8L2c+Cjwvc3ZnPgo='
- content: "\n# Filter and sort API objects\n\nYou can query the 2.0 API for specific objects using a simple language which resembles SQL.\n\n---\n**On this page**\n\n* [Supported endpoints](#supp-endpoints)\n* [Operators](#operators)\n* [Data types](#data-types)\n* [Querying](#querying)\n * [Repositoriess](#query-repo)\n * [Pull requests](#query-pullreq)\n * [Issues](#query-issues)\n * [Refs, tags, bookmarks](#query-ref)\n* [Sorting query results](#query-sort)\n\n----\n\n### Supported endpoints <a name=\"supp-endpoints\"></a>\n\nSeveral 2.0 API resources that return collections of objects all support a single, shared, generic querying language that is used to filter down a result set.\n\nCurrently, the endpoints which support filtering and sorting include:\n\n /2.0/repositories/{username}\n /2.0/repositories/{username}/{slug}/refs\n /2.0/repositories/{username}/{slug}/refs/branches\n /2.0/repositories/{username}/{slug}/refs/tags\n /2.0/repositories/{username}/{slug}/forks\n /2.0/repositories/{username}/{slug}/src\n /2.0/repositories/{username}/{slug}/issues\n /2.0/repositories/{username}/{slug}/pullrequests\n\nFiltering and sorting supports several distinct operators and data types as well as basic features, like logical operators (AND, OR) as shown in the following examples:\n\n\t(state = \"open\" OR state = \"new\") AND assignee = null\n\treporter.username != \"evzijst\" AND priority >= \"major\"\n\t(title ~ \"unicode\" OR content.raw ~ \"unicode\") AND created_on > 2015-10-04T14:00:00-07:00\n\nFilter queries can be added to the URL using the q=<query> query parameter. To sort the response, add sort=<field>. Note that the entire query string is put in the q parameter and hence needs to be URL-encoded as shown in the following example:\n\n\t/2.0/repositories/foo/bar/issues?q=state=\"new\"&sort=-updated_on\n\n### Operators <a name=\"operators\"></a>\n\nFiltering and sorting supports the following operators:\n\n<table class='aui'>\n <thead>\n <tr>\n <th>Operator</th>\n <th>Definition</th>\n <th>Example</th>\n </tr>\n </thead>\n <tr>\n <td>\"=\"</td>\n <td>test for equality </td>\n <td><code>username = \"evzijst\"</code></td>\n </tr>\n <tr>\n <td>\"!=\"</td>\n <td>not equal</td>\n <td><code>is_private != true</code></td>\n </tr>\n <tr>\n <td>\"~\"</td>\n <td>case-insensitive text contains </td>\n <td><code>description ~ \"beef\"</code></td>\n </tr>\n <tr>\n <td>\"!~\"</td>\n <td>case-insensitive not contains </td>\n <td><code>description !~ \"fubar\"</code></td>\n </tr>\n <tr>\n <td>\">\"</td>\n <td>greater than</td>\n <td><code>priority > \"major\"</code></td>\n </tr>\n <tr>\n <td>\">=\"</td>\n <td>greater than or equal</td>\n <td><code>priority <= \"trivial\"</code></td>\n </tr>\n <tr>\n <td>\"<\"</td>\n <td>less than</td>\n <td><code>id < 1234</code></td>\n </tr>\n <tr>\n <td>\"<=\"</td>\n <td>less than or equal </td>\n <td><code>updated_on <= 2015-03-04</code></td>\n </tr>\n</table>\n\n### Data types <a name=\"data-types\"></a>\n\nFiltering and sorting supports the following data types:\n\n<table class='aui'>\n <thead>\n <tr>\n <th>Type</th>\n <th>Description</th>\n <th>Example</th>\n </tr>\n </thead>\n <tr>\n <td><b>String</b></td>\n <td>any text inside double quotes</td>\n <td><code>\"foo\"</code></td>\n </tr>\n <tr>\n <td><b>Number</b></td>\n <td>arbitrary precision integers and floats</td>\n <td><code>1, -10.302</code></td>\n </tr>\n <tr>\n <td><b>Null</b></td>\n <td>to test for the absence of a value</td>\n <td><code>null</code></td>\n </tr>\n <tr>\n <td><b>boolean</b></td>\n <td>the unquoted strings true or false</td>\n <td><code>true, false</code></td>\n </tr>\n <tr>\n <td><b>datetime</b></td>\n <td>an unquoted <a href=\"https://en.wikipedia.org/wiki/ISO_8601\">ISO-8601</a> date time string with the timezone offset, milliseconds and entire time component being optional</td>\n <td><code>2015-03-04T14:08:59.123+02:00</code>, <code>2015-03-04T14:08:59</code> Date time strings are assumed to be in UTC, unless an explicit timezone offset is provided.</td>\n </tr>\n</table>\n\n## Querying <a name=\"querying\"></a>\n\nObjects can be filtered based on their properties. In principle, every element in an object's JSON document can be used as a filter criterion.\n\n### Repositories <a name=\"query-repo\"></a>\n\nYou can query the following fields in the repository resource:\n\n uuid (string)\n full_name (string)\n scm (string)\n owner (embedded user object)\n name (string)\n description (string)\n created_on (datetime)\n updated_on (datetime)\n size (number)\n language (string)\n parent (embedded repository object)\n fork_policy (string)\n is_private (boolean)\n has_issues (boolean)\n has_wiki (boolean)\n\nFields that contain embedded instances of other object types (e.g. owner is an embedded user object, while parent is an embedded repository) can be traversed recursively. For instance:\n\n\tparent.owner.username = \"bitbucket\"\n\n### Pull Requests <a name=\"query-pullreq\"></a>\n\nYou can query the following fields in the pull request resource:\n\n id (number)\n title (string)\n description (string)\n author (embedded user object)\n reviewers (embedded user object)\n state (string)\n source.repository (embedded repository object)\n source.branch.name (string)\n destination.repository (embedded repository object)\n destination.branch.name (string)\n close_source_branch (boolean)\n closed_by (embedded user object)\n reason (string)\n created_on (datetime)\n updated_on (datetime)\n task_count (number)\n comment_count (number)\n\n**For example**\n\nTo find pull requests which merge into master, come from a fork of the repo rather than a branch inside the repo, and on which I am a reviewer:\n\n```\nsource.repository.full_name != \"main/repo\" AND state = \"OPEN\" AND reviewers.username = \"evzijst\" AND destination.branch.name = \"master\"\n```\n```\n/2.0/repositories/main/repo/pullrequests?q=source.repository.full_name+%21%3D+%22main%2Frepo%22+AND+state+%3D+%22OPEN%22+AND+reviewers.username+%3D+%22evzijst%22+AND+destination.branch.name+%3D+%22master%22\n```\n\n### Issues <a name=\"query-issues\"></a>\n\nYou can query the following fields in the issues resource:\n\n id (number)\n title (string)\n reporter (embedded user object)\n assignee (embedded user object)\n content.raw (string)\n created_on (datetime)\n updated_on (datetime)\n state (string)\n kind (string)\n priority (string)\n version (string)\n component (string)\n milestone (string)\n watches (number)\n votes (number)\n\n**For example**\n\nTo find new or on-hold issues related to the UI, created or updated in the last day (SF local time), that have not yet been assigned to anyone:\n\n```\n(state = \"new\" OR state = \"on hold\") AND assignee = null AND component = \"UI\" and updated_on > 2015-11-11T00:00:00-07:00\n```\n```\n/2.0/repositories/main/repo/issues?q=%28state+%3D+%22new%22+OR+state+%3D+%22on+hold%22%29+AND+assignee+%3D+null+AND+component+%3D+%22UI%22+and+updated_on+%3E+2015-11-11T00%3A00%3A00-07%3A00\n```\n\n### Refs (Branches/Tags/Bookmarks) <a name=\"query-ref\"></a>\n\nYou can query the following fields in the refs resource:\n\n name (string)\n type (string)\n\n**For example**\n\nTo find all tags with the string \"2015\" in the name:\n\n```\nname ~ \"2015\"\n```\n```\n/2.0/repositories/{username}/{slug}/refs/tags?q=name+%7E+%222015%22\n```\nOr all my branches and bookmarks:\n\n```\nname ~ \"erik/\"\n```\n```\n/2.0/repositories/{username}/{slug}/refs/tags?q=name+%7E+%22erik%2F%22\n```\n## Sorting query results <a name=\"query-sort\"></a>\n\nYou can sort result sets using the ?sort=<field> query parameter, available on the same resources that support filtering:\n\n* In principle, every field that can be queried can also be used as a key for sorting.\n* By default the sort order is ascending. To reverse the order, prefix the field name with a hyphen (e.g. ?sort=-updated_on).\n* Only one field can be sorted on. Compound fields (e.g. sort on state first, followed by updated_on) are not supported.\n\n\n"
title: Filter and sort API objects
description: Query the 2.0 API for specific objects
key: filtering
icon: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMTk0LjE5MTkgMTQ3LjYwOTIiPgogIDxkZWZzPgogICAgPHN0eWxlPgogICAgICAuY2xzLTEgewogICAgICAgIGlzb2xhdGlvbjogaXNvbGF0ZTsKICAgICAgfQoKICAgICAgLmNscy0yIHsKICAgICAgICBmaWxsOiAjY2ZkNGRiOwogICAgICB9CgogICAgICAuY2xzLTMsIC5jbHMtNCB7CiAgICAgICAgZmlsbDogIzg3NzdkOTsKICAgICAgfQoKICAgICAgLmNscy00IHsKICAgICAgICBtaXgtYmxlbmQtbW9kZTogbXVsdGlwbHk7CiAgICAgIH0KCiAgICAgIC5jbHMtNSB7CiAgICAgICAgZmlsbDogIzAwNjVmZjsKICAgICAgfQoKICAgICAgLmNscy02IHsKICAgICAgICBmaWxsOiAjY2NlMGZmOwogICAgICB9CgogICAgICAuY2xzLTcgewogICAgICAgIGZpbGw6IHVybCgjb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w2Ni43OTc0LDAsMCwxLDUxLjE4MzcsMS45NjY2bC4wMDA3LDBBNjYuNzk2Miw2Ni43OTYyLDAsMCwxLDEwMi4wNTEsOS43NTI1aDBBNjcuMjM0Niw2Ny4yMzQ2LDAsMCwxLDgzLjI1MzcsMTMyLjU1NloiLz4KICAgICAgICA8cGF0aCBpZD0iX1BhdGhfMiIgZGF0YS1uYW1lPSImbHQ7UGF0aCZndDsiIGNsYXNzPSJjbHMtNiIgZD0iTTIzLjQzOSw0MC43NDgyQTUxLjE5MDgsNTEuMTkwOCwwLDAsMCwxMTEuMDEsOTMuNzg4OSw1MS4xOTA4LDUxLjE5MDgsMCwwLDAsMjMuNDM5LDQwLjc0ODJaIi8+CiAgICAgICAgPHBhdGggY2xhc3M9ImNscy03IiBkPSJNNzkuNDMzLDExNi45ODJBNTEuMjE2Miw1MS4yMTYyLDAsMCwwLDExOC40MjQxLDY3LjAzN2E0OS4xMzkxLDQ5LjEzOTEsMCwwLDEtNS4wODY3LDIuMjc4OWMtMTUuNzAyOSw1Ljk2MDktMjkuNjg5NSwyLjExLTM2LjQ5ODcuMTMwOC0yMC40MzA3LTUuOTM5LTI0Ljc5LTE3LjM3ODUtMzkuMDQxNC0yNC41ODIzYTQ4LjMwOTIsNDguMzA5MiwwLDAsMC0xNC4wOTM5LTQuNTNjLS4wODYyLjEzOTUtLjE3OTMuMjczLS4yNjQ0LjQxMzVBNTEuMTkwNyw1MS4xOTA3LDAsMCwwLDc5LjQzMywxMTYuOTgyWiIvPgogICAgICA8L2c+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K'
- content: |
# Pagination
Endpoints that return collections of objects should always apply pagination.
Paginated collections are always wrapped in the following wrapper object:
```json
{
"size": 5421,
"page": 2,
"pagelen: 10,
"next": "https://api.bitbucket.org/2.0/repositories/pypy/pypy/commits?page=3",
"previous": "https://api.bitbucket.org/2.0/repositories/pypy/pypy/commits?page=1",
"values": [
...
]
}
```
Pagination is often page-bound, with a query parameter page indicating which
page is to be returned.
However, clients are not expected to construct URLs themselves by manipulating
the page number query parameter. Instead, the response contains a link to the
next page. This link should be treated as an opaque location that is not to be
constructed by clients or even assumed to be predictable. The only contract
around the next link is that it will return the next chunk of results.
Lack of a next link in the response indicates the end of the collection.
The paginated response contains the following fields:
<table class='aui'>
<thead>
<tr>
<th>Field</th>
<th>Value</th>
</tr>
</thead>
<tr>
<td><code>size</code></td>
<td>Total number of objects in the response. This is an optional element that is not provided in all responses, as it can be expensive to compute. </td>
</tr>
<tr>
<td><code>page</code></td>
<td>Page number of the current results. This is an optional element that is not provided in all responses.</td>
</tr>
<tr>
<td><code>pagelen</code></td>
<td>Current number of objects on the existing page. Globally, the minimum length is 10 and the maximum is 100. Some APIs may specify a different default.</td>
</tr>
<tr>
<td><code>next</code></td>
<td>Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs.</td>
</tr>
<tr>
<td><code>previous</code></td>
<td>Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available.
Use this link to navigate the result set and refrain from constructing your own URLs.</td>
</tr>
<tr>
<td><code>values</code></td>
<td>The list of objects. This contains at most <code>pagelen</code> objects.</td>
</tr>
</table>
The link to the next page is included such that you don't have to hardcode or construct any links. Only values and next are guaranteed (except the last page, which lacks next). This is because the previous and size values can be expensive for some data sets.
It is important to realize that Bitbucket support both list-based pagination and iterator-based pagination. List-based pagination assumes that the collection is a discrete, immutable, consistently ordered, finite array of objects with a fixed size. Clients navigate a list-based collection by requesting offset-based chunks. In Bitbucket Cloud, list-based responses include the optional size, page, and previous element. The the next and previous links typically resemble something like /foo/bar?page=4.
However, not all result sets can be treated as immutable and finite – much like how programming languages tend to distinguish between lists and arrays on one hand and iterators or stream on the other. Where an list-based pagination offers random access into any point in a collection, iterator-based pagination can only navigate forward one element at a time. In Bitbucket such iterator-based pagination contains the next link and pagelen elements, but not necessarily anything else. In these cases, the next link's value often contains an unpredictable hash instead of an explicit page number. The commits resource uses iterator-based pagination.
title: Pagination
description: Learn more about pagination
key: pagination
icon: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMjM4LjgyIDE1MS42Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2IyZDRmZjt9LmNscy0ye2ZpbGw6IzRjOWFmZjt9LmNscy0ze2ZpbGw6IzAwNTJjYzt9LmNscy00e29wYWNpdHk6MC42O30uY2xzLTV7ZmlsbDp1cmwoI2xpbmVhci1ncmFkaWVudCk7fS5jbHMtNntmaWxsOnVybCgjbGluZWFyLWdyYWRpZW50LTIpO30uY2xzLTd7ZmlsbDp1cmwoI2xpbmVhci1ncmFkaWVudC0zKTt9LmNscy04e2ZpbGw6dXJsKCNsaW5lYXItZ3JhZGllbnQtNCk7fS5jbHMtOXtmaWxsOnVybCgjbGluZWFyLWdyYWRpZW50LTUpO30uY2xzLTEwLC5jbHMtMTEsLmNscy0xMntmaWxsOm5vbmU7fS5jbHMtMTB7c3Ryb2tlOiMzMzg0ZmY7fS5jbHMtMTAsLmNscy0xMSwuY2xzLTEyLC5jbHMtMTN7c3Ryb2tlLW1pdGVybGltaXQ6MTA7c3Ryb2tlLXdpZHRoOjJweDt9LmNscy0xMXtzdHJva2U6I2ZmYWIwMDt9LmNscy0xMntzdHJva2U6I2ZhZmJmYzt9LmNscy0xM3tmaWxsOiNmZmFiMDA7c3Ryb2tlOiMyNjg0ZmY7fTwvc3R5bGU+PGxpbmVhckdyYWRpZW50IGlkPSJsaW5lYXItZ3JhZGllbnQiIHkxPSI2NS4xNyIgeDI9Ijg2LjM4IiB5Mj0iNjUuMTciIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj48c3RvcCBvZmZzZXQ9I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
By default, each endpoint returns the full representation of a resource and in
some cases that can be a lot of data. For example, retrieving a list of pull
requests can amount to quite a large document.
For better performance, you can ask the server to only return the fields you
really need and to omit unwanted data. To request a partial response and to
add or remove specific fields from a response, use the `fields` query
parameter.
## Example
Most API resources embed a substantial list of links pointing to related
resources. This saves the client from constructing its own URLs, but is
somewhat wasteful when the client doesn't need them.
To significantly reduce the size of the response, use `?fields=-links`:
```
$ curl https://api.bitbucket.org/2.0/users/evzijst?fields=-links
{
"username": "evzijst",
"website": "",
"display_name": "Erik van Zijst",
"uuid": "{a288a0ab-e13b-43f0-a689-c4ef0a249875}",
"created_on": "2010-07-07T05:16:36+00:00",
"location": null,
"type": "user"
}
```
## Fields parameter syntax
The `fields` parameter supports 3 modes of operation:
1. Removal of select fields (e.g. `-links`)
2. Pulling in additional fields not normally returned by an endpoint, while
still getting all the default fields (e.g. `+reviewers`)
3. Omitting all fields, except those specified (e.g. `owner.username`)
The fields parameter can contain a list of multiple comma-separated field names
(e.g. `fields=owner.username,uuid,links.self.href`). The parameter itself is
not repeated.
As discussed at [Condensed Versus Full Objects](serialization#representations),
most objects that are embedded inside other objects (like how `owner` is an
embedded `user` object in `repository`) appear in "condensed" form that omits
many fields. The `fields` parameter allows us to pull in additional fields in
such cases.
For example, the embedded repository object in a pull request does not normally
contain its `owner`. To add that in we can use:
`+values.destination.repository.owner`.
## Wildcards
The asterisk can be used to match all fields on a particular level. For
example, removing all entries from the `links` element can be done like this:
```
$ curl https://api.bitbucket.org/2.0/users/evzijst?fields=-links.*
{
"username": "evzijst",
"website": "",
"display_name": "Erik van Zijst",
"uuid": "{a288a0ab-e13b-43f0-a689-c4ef0a249875}",
"links": {},
"created_on": "2010-07-07T05:16:36+00:00",
"location": null,
"type": "user"
}
```
Wildcards can be used in combination with exclusion and inclusion. For
instance, `-*,+foo,+bar` will remove all elements from the root level and then
add in `foo` and `bar`.
## URL encoding
Be aware that when using the `+foo.bar` syntax in the query string, that the
"+" must be URL encoded as "%2B" and so the URL will be:
```
https://api.bitbucket.org/2.0/repositories/evzijst/interruptingcow?fields=%2Bowner.created_on
```
Without URL escaping, "+" is interpreted as an encoded space which will not
match any fields.
## Field discovery
While a resource's `self` URL, as well its "collection" URL typically return
the full object with all its fields, there are some exceptions for fields that
are overly verbose or costly to generate.
For instance, a pull request contains the embedded lists of reviewers and
participants. These fields are included from the `self` URL, but not from the
`/pullrequests` collections resource, as it would impact performance too much.
To discover any additional fields that might not be included by default,
`fields=*` can be used.
## More examples
If we want to get a list of all reviewer usernames on pull requests I created,
we could combine a [filter](filtering) with a partial response. This will omit
all other data from the response:
```
/2.0/repositories/bitbucket/bitbucket/pullrequests?fields=values.id,values.reviewers.username,values.state&q=author.username%3D%22erik%22
{
"values": [
{
"reviewers": [
{
"username": "abhin"
},
{
"username": "dtao"
},
{
"username": "csomme"
}
],
"state": "OPEN",
"id": 11355
},
{
"reviewers": [
{
"username": "csomme"
},
{
"username": "abhin"
},
{
"username": "dstevens"
}
],
"state": "MERGED",
"id": 11347
},
{
"reviewers": [
{
"username": "csomme"
},
{
"username": "jmooring"
},
{
"username": "zdavis"
},
{
"username": "flexbox"
}
],
"state": "OPEN",
"id": 11344
}
]
}
```
title: Partial responses
description: Tweak which fields are returned
key: partial-response
icon: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMTYyLjQ0ODcgMjEwLjExMTUiPgogIDxkZWZzPgogICAgPHN0eWxlPgogICAgICAuY2xzLTEgewogICAgICAgIGlzb2xhdGlvbjogaXNvbGF0ZTsKICAgICAgfQoKICAgICAgLmNscy0yLCAuY2xzLTYsIC5jbHMtOCB7CiAgICAgICAgZmlsbDogbm9uZTsKICAgICAgfQoKICAgICAgLmNscy0yLCAuY2xzLTggewogICAgICAgIHN0cm9rZTogIzAwNjVmZjsKIC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zA1IiB4Mj0iNzkuMTEzNSIgeTI9IjM2LjE3MDUiLz4KICAgICAgICA8bGluZSBjbGFzcz0iY2xzLTgiIHgxPSIxOC4zOTczIiB5MT0iMjYuNTgzOCIgeDI9Ijc5LjExMzUiIHkyPSIyNi41ODM4Ii8+CiAgICAgICAgPHBvbHlnb24gY2xhc3M9ImNscy05IiBwb2ludHM9IjE2Mi40NDkgMzguNzQyIDEyMy43MDcgMzguNzQyIDEyMy43MDcgMCAxNjIuNDQ5IDM4Ljc0MiIvPgogICAgICA8L2c+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K'
- content: |
# Open API Specification and Object Representations
----
*On this page*
* [Open API Specification](#oai)
* [JSON Schema](#jsonschema)
* [Condensed Versus Full Objects](#representations)
____
## Open API Specification <a name="aoi"></a>
Bitbucket uses the [Open API Specification](https://openapis.org) (OAI,
formerly known as Swagger) to describe its APIs. Our OAI specification schema
is hosted at [https://api.bitbucket.org/swagger.json](https://api.bitbucket.org/swagger.json)
and serves as the canonical definition and comprehensive declaration of all
available endpoints.
The OAI specification makes writing client applications easier by:
auto-generating boilerplate code (like data object classes) and dealing with
authentication and error handling.
You can find a comprehensive set of open tools for the OAI specification at:
[https://github.com/swagger-api](https://github.com/swagger-api).
## JSON Schema <a name="jsonschema"></a>
Bitbucket uses JSON Schema to describe the layout of every type of object
consumed or produced by the API. These schemas are collected under the
`#definitions` element of our swagger.json file.
When an endpoint expects an object as part of a POST or PUT, it also expects
the object to validate against the JSON schemas. The same applies to objects
returned by an endpoint.
## Condensed Versus Full Objects <a name="representations"></a>
Most objects in Bitbucket come both in "full" and "partial" representation.
The full representation is when all elements are included. This is the layout
returned by a resource's `self` location (e.g. `/2.0/repositories/foo/bar`),
as well as resource collection endpoints (e.g. `/2.0/repositories`).
However, Bitbucket objects often embed other objects. For example, a `repository`
object embeds a `user` object for its owner. Likewise, a `pullrequest` object
embeds its `repository` object.
These related objects are embedded, or inlined, to reduce the "chatter" when
clients make frequent followup API calls to collect information on common,
related information.
Embedded related objects are typically limited in their fields to avoid such
object graphs from becoming too deep and noisy. They often exclude their own
nested objects in an attempt to strike a balance between performance and
utility.
An object's embedded or condensed representation tends to be standardized,
meaning the fields included is the same set, regardless of where the object
was embedded.
title: Schemas and Serialization
description: Learn more about object representations
key: serialization
icon: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMjAuNzYyNCAyMDUuNTg2Ij4KICA8ZGVmcz4KICAgIDxzdHlsZT4KICAgICAgLmNscy0xIHsKICAgICAgICBpc29sYXRpb246IGlzb2xhdGU7CiAgICAgIH0KCiAgICAgIC5jbHMtMiwgLmNscy02IHsKICAgICAgICBtaXgtYmxlbmQtbW9kZTogbXVsdGlwbHk7CiAgICAgIH0KCiAgICAgIC5jbHMtMTMsIC5jbHMtMywgLmNscy00LCAuY2xzLTYgewogICAgICAgIGZpbGw6IG5vbmU7CiAgICAgICAgc3Ryb2tlOiAjYzFjN2QwOwogICAgICAgIHN0cm9rZS1saW5lY2FwOiByb3VuZDsKICAgICAgICBzdHJva2UtbWl0ZXJsaW1pdDogMTA7CiAgICAgICAgc3Ryb2tlLXdpZHRoOiAycHg7CiAgICAgIH0KCiAgICAgIC5jbHMtNCB7CiAgICAgICAgc3Ryb2tlLWRhc2hhcnJheTogMy43ODE2IDUuMjk0MzsKICAgICAgfQoKICAgICAgLmNscy01IHsKICAgICAgICBmaWxsOiAjMDA2NWZmOwogICAgICB9CgogICAgICAuY2xzLTYgewogICAgICAgIHN0cm9rZS1kYXNoYXJyYXk6IDMuOTIxOSA1LjQ5MDc7CiAgICAgIH0KCiAgICAgIC5jbHMtNyB7CiAgICAgICAgZmlsbDogIzAwNTJjYzsKICAgICAgfQoKICAgICAgLmNscy04IHsKICAgICAgICBmaWxsOiAjNGM5YWZmOwogICAgICB9CgogICAgICAuY2xzLTkgewogICAgICAgIGZpbGw6ICMwMDQ5YjA7CiAgIC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TUgNzQuODc1IDE4NS42NjIgNTcuMTM5IDE3NC4xMzIgNzQuNjY0IDE2Mi4yOTEgOTIuMzk0IDE3My44MTUiLz4KICAgICAgICA8cG9seWdvbiBjbGFzcz0iY2xzLTE1IiBwb2ludHM9Ijc0Ljg3NSAxODUuNjYyIDc1LjA1NCAyMDUuNTg2IDU3LjMxOSAxOTQuMDU3IDU3LjEzOSAxNzQuMTMyIDc0Ljg3NSAxODUuNjYyIi8+CiAgICAgICAgPHBvbHlnb24gY2xhc3M9ImNscy0xNiIgcG9pbnRzPSI5Mi4zOTQgMTczLjgxNSA5Mi41NzQgMTkzLjczOSA3NS4wNTQgMjA1LjU4NiA3NC44NzUgMTg1LjY2MiA5Mi4zOTQgMTczLjgxNSIvPgogICAgICA8L2c+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K'
- content: |
# URI, UUID, and structures
You should be familiar with REST architecture before writing an integration. Read this overview page to gain a good understanding of Bitbucket's REST implementation.
----
**On this page**
* [URI structure](#uri-structure)
* [HTTP methods](#http-methods)
* [UUID](#uuid)
* [User object and UUID](#userobj)
* [Repository object and UUID](#repo-obj)
* [Team object and UUID](#teamobj)
* [Standard error repsponses](#stand-error)
* [Standard ISO-8601 timestamps](#timestamp)
----
## URI structure <a name="uri-structure"></a>
All Bitbucket Cloud requests start with the `https://api.bitbucket.org/2.0` prefix (for the 2.0 API) and `https://api.bitbucket.org/1.0` prefix (1.0 API).
The next segment of the URI path depends on the endpoint of the request. For example, using the curl command and the repositories endpoint you can list all the issues on Bitbucket's tutorial repository:
```
curl https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org
```
Given a specific endpoint, you can then drill down to a particular aspect or resource of that endpoint. The issues resource on a repository is an example:
```
curl https://api.bitbucket.org/1.0/repositories/tutorials/tutorials.bitbucket.org/issues
```
### HTTP methods <a name="http-methods"></a>
A given endpoint or resource has a series of actions (or methods) associated with it. The Bitbucket service supports these standard HTTP methods:
<table class='aui'>
<thead>
<tr>
<th>Call</th>
<th>Description</th>
</tr>
</thead>
<tr>
<td>GET</td>
<td>Retrieves information. </td>
</tr>
<tr>
<td>PUT</td>
<td>Updates existing information.</td>
</tr>
<tr>
<td>POST</td>
<td>Creates new information.</td>
</tr>
<tr>
<td>DELETE</td>
<td>Removes existing information.</td>
</tr>
</table>
For example, you can call use the POST action on the issues resource and create an issue on the issue tracker.
**Specifying content length**
You can get a `411 Length Required` response. If this happens, the API requires a Content-Length header but the client is not sending it. You should add the header yourself, for example using the curl client:
```
curl -r PUT --header "Content-Length: 0" -u user:pass https://api.bitbucket.org/1.0/emails/[email protected]
```
## Universally Unique Identifier <a name="uuid"></a>
UUID's provide a single point of recognition for users, teams, and repositories. The UUID is distinct from the username, team name, and repository name fields and remains the same even when those fields change. For example when a user changes their username or moves a repository you will need to modify calls which use those identifiers but not if you are pointing to the UUID.
### UUID examples and structure
UUID's work with both the 1.0 and 2.0 APIs for the user, team, and repository objects. The following examples the following characters are replacements for curly brackets: `%7B` replaces `{` and `%7D` replaces `}`. You will see this structure in the following example sections.
### User object and UUID <a name="userobj"></a>
When you make a call using either the username or the UUID for that user the response is the same.
**Call with username**:
```
curl https://api.bitbucket.org/2.0/users/tutorials
```
***Call with UUID for the user**:
```
curl https://api.bitbucket.org/2.0/users/%7Bc788b2da-b7a2-404c-9e26-d3f077557007%7D
```
**Response**
```JSON
{
"username": "tutorials",
"website": "https://tutorials.bitbucket.org/",
"display_name": "tutorials account",
"uuid": "{c788b2da-b7a2-404c-9e26-d3f077557007}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/tutorials"
},
"repositories": {
"href": "https://api.bitbucket.org/2.0/repositories/tutorials"
},
"html": {
"href": "https://bitbucket.org/tutorials"
},
"followers": {
"href": "https://api.bitbucket.org/2.0/users/tutorials/followers"
},
"avatar": {
"href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2013/Nov/25/tutorials-avatar-1563784409-6_avatar.png"
},
"following": {
"href": "https://api.bitbucket.org/2.0/users/tutorials/following"
}
},
"created_on": "2011-12-20T16:34:07.132459+00:00",
"location": "Santa Monica, CA",
"type": "user"
}
```
### Repository object and UUID <a name="repo-obj"></a>
Once you have the UUID for a repository you no longer need a username or team name to make the API call so long as you use an empty field. This helps you resolve repositories no matter if the username or team name changes.
**Call with team name (1team) and repository name (moxie)**:
```
curl https://api.bitbucket.org/2.0/repositories/1team/moxie
```
**Call with UUID and empty field**:
```
curl https://api.bitbucket.org/2.0/repositories/%7B%7D/%7B21fa9bf8-b5b2-4891-97ed-d590bad0f871%7D
```
**Call with UUID and teamname**:
```
curl https://api.bitbucket.org/2.0/repositories/1team/%7B21fa9bf8-b5b2-4891-97ed-d590bad0f871%7D
```
**Response**
```JSON
{
"created_on": "2013-11-08T01:11:03.222520+00:00",
"description": "",
"fork_policy": "allow_forks",
"full_name": "1team/moxie",
"has_issues": false,
"has_wiki": false,
"is_private": false,
"language": "",
"links": {
"avatar": {
"href": "https://bitbucket.org/1team/moxie/avatar/32/"
},
"branches": {
"href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/refs/branches"
},
"clone": [
{
"href": "https://bitbucket.org/1team/moxie.git",
"name": "https"
},
{
"href": "ssh://[email protected]/1team/moxie.git",
"name": "ssh"
}
],
"commits": {
"href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/commits"
},
"downloads": {
"href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/downloads"
},
"forks": {
"href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/forks"
},
"hooks": {
"href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/hooks"
},
"html": {
"href": "https://bitbucket.org/1team/moxie"
},
"pullrequests": {
"href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/pullrequests"
},
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/1team/moxie"
},
"tags": {
"href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/refs/tags"
},
"watchers": {
"href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/watchers"
}
},
"name": "moxie",
"owner": {
"display_name": "the team",
"links": {
"avatar": {
"href": "https://bitbucket.org/account/1team/avatar/32/"
},
"html": {
"href": "https://bitbucket.org/1team/"
},
"self": {
"href": "https://api.bitbucket.org/2.0/teams/1team"
}
},
"type": "team",
"username": "1team",
"uuid": "{aa559944-83c9-4963-a9a8-69ac8d9cf5d2}"
},
"project": {
"key": "PROJ",
"links": {
"avatar": {
"href": "https://bitbucket.org/account/user/1team/projects/PROJ/avatar/32"
},
"html": {
"href": "https://bitbucket.org/account/user/1team/projects/PROJ"
}
},
"name": "Untitled project",
"type": "project",
"uuid": "{ab52aaeb-16ad-4fb0-bb1d-47e4f00367ff}"
},
"scm": "git",
"size": 33348,
"type": "repository",
"updated_on": "2013-11-08T01:11:03.263237+00:00",
"uuid": "{21fa9bf8-b5b2-4891-97ed-d590bad0f871}",
"website": ""
}
```
### Team object and UUID <a name="teamobj"></a>
This example shows a call for a list of team members using both the team name and with the UUID for the team object. As the call is unauthenticated in the following example the response object will only show members with public profiles. The response is the same in either case.
**Call with teamname**
```
curl https://api.bitbucket.org/2.0/teams/1team/members
```
**Call with UUID for team object**
```
curl https://api.bitbucket.org/2.0/teams/%7Baa559944-83c9-4963-a9a8-69ac8d9cf5d2%7D/members
```
**Response**
```JSON
{
"page": 1,
"pagelen": 50,
"size": 2,
"values": [
{
"created_on": "2011-12-20T16:34:07.132459+00:00",
"display_name": "tutorials account",
"links": {
"avatar": {
"href": "https://bitbucket.org/account/tutorials/avatar/32/"
},
"followers": {
"href": "https://api.bitbucket.org/2.0/users/tutorials/followers"
},
"following": {
"href": "https://api.bitbucket.org/2.0/users/tutorials/following"
},
"hooks": {
"href": "https://api.bitbucket.org/2.0/users/tutorials/hooks"
},
"html": {
"href": "https://bitbucket.org/tutorials/"
},
"repositories": {
"href": "https://api.bitbucket.org/2.0/repositories/tutorials"
},
"self": {
"href": "https://api.bitbucket.org/2.0/users/tutorials"
},
"snippets": {
"href": "https://api.bitbucket.org/2.0/snippets/tutorials"
}
},
"location": null,
"type": "user",
"username": "tutorials",