github.com/cozy/cozy-stack@v0.0.0-20240327093429-939e4a21320e/docs/sharing.md (about)

     1  [Table of contents](README.md#table-of-contents)
     2  
     3  # Sharing
     4  
     5  The owner of a cozy instance can share access to her documents to other users.
     6  
     7  ## Sharing by links
     8  
     9  A client-side application can propose sharing by links:
    10  
    11  1. The application must have a public route in its manifest. See
    12     [Apps documentation](apps.md#routes) for how to do that.
    13  2. The application can create a set of permissions for the shared documents,
    14     with codes. Another code called `shortcode` is also generated and associated
    15     with the code. This `shortcode` is much smaller (but secure), which is
    16     easier to be shared. See [permissions documentation](permissions.md) for the
    17     details.
    18  3. The application can then create a shareable link (e.g.
    19     `https://calendar.cozy.example.net/public?sharecode=eiJ3iepoaihohz1Y`) by
    20     putting together the app sub-domain, the public route path, and a code for
    21     the permissions set.
    22  4. The app can then send this link by mail, via the [jobs system](jobs.md), or
    23     just give it to the user, so he can transmit it to her friends via chat or
    24     other ways.
    25  
    26  When someone opens the shared link, the stack will load the public route, find
    27  the corresponding `index.html` file, and replace `{{.Token}}` inside it by a
    28  token with the same set of permissions that `sharecode` offers. This token can
    29  then be used as a `Bearer` token in the `Authorization` header for requests to
    30  the stack (or via cozy-client-js).
    31  
    32  NB: The `shortcode` can also be used as the `Bearer`. In this case, the
    33  corresponding `sharecode` will be matched on server-side
    34  
    35  If necessary, the application can list the permissions for the token by calling
    36  `/permissions/self` with this token.
    37  
    38  ## Cozy to cozy sharing
    39  
    40  The owner of a cozy instance can send and synchronize documents to others cozy
    41  users.
    42  
    43  ### Intents
    44  
    45  When a sharing is authorized, the user is redirected to their cozy on the
    46  application that was used for the sharing (when possible). It's possible to use
    47  a specific route to do so, via the intents. The application must declare an
    48  intent in its manifest for the action `SHARING`. The doctype of the intent must
    49  be the same as the doctype of the first rule of the sharing. In the redirect
    50  URL, the query string will have a `sharing` parameter with the sharing ID (but
    51  no intent parameter).
    52  
    53  ### Routes
    54  
    55  #### POST /sharings/
    56  
    57  Create a new sharing. The sharing rules and recipients must be specified. The
    58  `description`, `preview_path`, and `open_sharing` fields are optional. The
    59  `app_slug` field is optional and is the slug of the web app by default.
    60  
    61  [See the doc on io.cozy.sharings for in-depth explanation of all attributes](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.sharings/).
    62  
    63  To create a sharing, no permissions on `io.cozy.sharings` are needed: an
    64  application can create a sharing on the documents for whose it has a permission.
    65  
    66  ##### Request
    67  
    68  ```http
    69  POST /sharings/ HTTP/1.1
    70  Host: alice.example.net
    71  Content-Type: application/vnd.api+json
    72  ```
    73  
    74  ```json
    75  {
    76    "data": {
    77      "type": "io.cozy.sharings",
    78      "attributes": {
    79        "description": "sharing test",
    80        "preview_path": "/preview-sharing",
    81        "rules": [
    82          {
    83            "title": "Hawaii",
    84            "doctype": "io.cozy.files",
    85            "values": ["612acf1c-1d72-11e8-b043-ef239d3074dd"],
    86            "add": "sync",
    87            "update": "sync",
    88            "remove": "sync"
    89          }
    90        ]
    91      },
    92      "relationships": {
    93        "recipients": {
    94          "data": [
    95            {
    96              "id": "2a31ce0128b5f89e40fd90da3f014087",
    97              "type": "io.cozy.contacts"
    98            },
    99            {
   100              "id": "51bbc980acb0013cb5f618c04daba326",
   101              "type": "io.cozy.contacts.groups"
   102            }
   103          ]
   104        }
   105      }
   106    }
   107  }
   108  ```
   109  
   110  #### Response
   111  
   112  ```http
   113  HTTP/1.1 200 OK
   114  Content-Type: application/vnd.api+json
   115  ```
   116  
   117  ```json
   118  {
   119    "data": {
   120      "type": "io.cozy.sharings",
   121      "id": "ce8835a061d0ef68947afe69a0046722",
   122      "meta": {
   123        "rev": "1-4859c6c755143adf0838d225c5e97882"
   124      },
   125      "attributes": {
   126        "description": "sharing test",
   127        "preview_path": "/preview-sharing",
   128        "app_slug": "drive",
   129        "owner": true,
   130        "created_at": "2018-01-04T12:35:08Z",
   131        "updated_at": "2018-01-04T13:45:43Z",
   132        "members": [
   133          {
   134            "status": "owner",
   135            "public_name": "Alice",
   136            "email": "alice@example.net",
   137            "instance": "alice.example.net"
   138          },
   139          {
   140            "status": "mail-not-sent",
   141            "name": "Bob",
   142            "email": "bob@example.net"
   143          },
   144          {
   145            "status": "mail-not-sent",
   146            "name": "Gaby",
   147            "email": "gaby@example.net",
   148            "only_in_groups": true,
   149            "groups": [0]
   150          }
   151        ],
   152        "groups": [
   153          {
   154            "id": "51bbc980acb0013cb5f618c04daba326",
   155            "name": "G. people",
   156            "addedBy": 0
   157          }
   158        ],
   159        "rules": [
   160          {
   161            "title": "Hawaii",
   162            "doctype": "io.cozy.files",
   163            "values": ["612acf1c-1d72-11e8-b043-ef239d3074dd"],
   164            "add": "sync",
   165            "update": "sync",
   166            "remove": "sync"
   167          }
   168        ]
   169      },
   170      "links": {
   171        "self": "/sharings/ce8835a061d0ef68947afe69a0046722"
   172      }
   173    }
   174  }
   175  ```
   176  
   177  ### GET /sharings/:sharing-id/discovery
   178  
   179  If no preview_path is set, it's an URL to this route that will be sent to the
   180  users to notify them that someone wants to share something with them. On this
   181  page, they can fill the URL of their Cozy (if the user has already filled its
   182  Cozy URL in a previous sharing, the form will be pre-filled and the user will
   183  just have to click OK).
   184  
   185  #### Query-String
   186  
   187  | Parameter | Description                        |
   188  | --------- | ---------------------------------- |
   189  | state     | a code that identify the recipient |
   190  
   191  #### Example
   192  
   193  ```http
   194  GET /sharings/ce8835a061d0ef68947afe69a0046722/discovery?state=eiJ3iepoaihohz1Y HTTP/1.1
   195  Host: alice.example.net
   196  ```
   197  
   198  ### POST /sharings/:sharing-id/discovery
   199  
   200  Give to the cozy of the sharer the URL of the Cozy of one recipient. The sharer
   201  will register its-self as an OAuth client on the recipient cozy, and then will
   202  ask the recipient to accept the permissions on its instance.
   203  
   204  This route exists in two versions, the version is selected by the HTTP header
   205  `Accept`
   206  
   207  #### Classical (`x-www-form-urlencoded`)
   208  
   209  | Parameter | Description                           |
   210  | --------- | ------------------------------------- |
   211  | state     | a code that identify the recipient    |
   212  | url       | the URL of the Cozy for the recipient |
   213  
   214  ##### Example
   215  
   216  ```http
   217  POST /sharings/ce8835a061d0ef68947afe69a0046722/discovery HTTP/1.1
   218  Host: alice.example.org
   219  Content-Type: application/x-www-form-urlencoded
   220  Accept: text/html
   221  
   222  state=eiJ3iepoaihohz1Y&url=https://bob.example.net/
   223  ```
   224  
   225  ```http
   226  HTTP/1.1 302 Moved Temporarily
   227  Location: https://bob.example.net/auth/sharing?...
   228  ```
   229  
   230  #### JSON
   231  
   232  This version can be more convenient for applications that implement the preview
   233  page. To do that, an application must give a `preview_path` when creating the
   234  sharing. This path must be a public route of this application. The recipients
   235  will receive a link to the application subdomain, on this page, and with a
   236  `sharecode` in the query string (like for a share by link).
   237  
   238  To know the `sharing-id`, it's possible to ask `GET /permissions/self`, with the
   239  `sharecode` in the `Authorization` header (it's a JWT token). In the response,
   240  the `source_id` field will be `io.cozy.sharings/<sharing-id>`.
   241  
   242  ##### Parameters
   243  
   244  | Parameter | Description                           |
   245  | --------- | ------------------------------------- |
   246  | sharecode | a code that identify the recipient    |
   247  | url       | the URL of the Cozy for the recipient |
   248  
   249  ##### Example
   250  
   251  ```http
   252  POST /sharings/ce8835a061d0ef68947afe69a0046722/discovery HTTP/1.1
   253  Host: alice.example.org
   254  Content-Type: application/x-www-form-urlencoded
   255  Accept: application/json
   256  
   257  sharecode=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhcHAiLCJpYXQiOjE1MjAzNDM4NTc&url=https://bob.example.net/
   258  ```
   259  
   260  ```http
   261  HTTP/1.1 200 OK
   262  Content-Type: application/json
   263  ```
   264  
   265  ```json
   266  {
   267    "redirect": "https://bob.example.net/auth/sharing?..."
   268  }
   269  ```
   270  
   271  ### POST /sharings/:sharing-id/preview-url
   272  
   273  This internal route can be used by the stack to get the URL where a member can
   274  preview the sharing.
   275  
   276  #### Request
   277  
   278  ```http
   279  POST /sharings/ce8835a061d0ef68947afe69a0046722/discovery-url HTTP/1.1
   280  Host: alice.example.net
   281  Content-Type: application/json
   282  ```
   283  
   284  ```json
   285  {
   286    "state": "eiJ3iepoaihohz1Y"
   287  }
   288  ```
   289  
   290  #### Response
   291  
   292  ```http
   293  HTTP/1.1 200 OK
   294  Content-Type: application/json
   295  ```
   296  
   297  ```json
   298  {
   299    "url": "https://drive.alice.example.net/preview?sharecode=..."
   300  }
   301  ```
   302  
   303  ### GET /sharings/:sharing-id
   304  
   305  Get the information about a sharing. This includes the content of the rules, the
   306  members, as well as the already shared documents for this sharing.
   307  
   308  For a member, we can have the following fields:
   309  
   310  - a contact name (`name`), that is the name of this user as it appears in its
   311    contact document (if there is one such document)
   312  - a public name (`public_name`), that is the name this user has put on his
   313    cozy as a public name (it is used for sending emails for example)
   314  - an email addresse (`email`)
   315  - an instance URL (`instance`)
   316  - and a status (`status`).
   317  
   318  **Notes:**
   319  
   320  - the first member is always the sharer
   321  - to display the list of members to a user, the `name` should be use if
   322    available, and if it is not the case, you can use the `public_name` or the
   323    `email`
   324  - on a recipient, the only member with an `instance` is the local user.
   325  
   326  #### Request
   327  
   328  ```http
   329  GET /sharings/ce8835a061d0ef68947afe69a0046722 HTTP/1.1
   330  Host: alice.example.net
   331  Accept: application/vnd.api+json
   332  ```
   333  
   334  #### Response
   335  
   336  ```http
   337  HTTP/1.1 200 OK
   338  Content-Type: application/vnd.api+json
   339  ```
   340  
   341  ```json
   342  {
   343    "data": {
   344      "type": "io.cozy.sharings",
   345      "id": "ce8835a061d0ef68947afe69a0046722",
   346      "meta": {
   347        "rev": "1-4859c6c755143adf0838d225c5e97882"
   348      },
   349      "attributes": {
   350        "description": "sharing test",
   351        "preview_path": "/preview-sharing",
   352        "app_slug": "drive",
   353        "owner": true,
   354        "created_at": "2018-01-04T12:35:08Z",
   355        "updated_at": "2018-01-04T13:45:43Z",
   356        "initial_number_of_files_to_sync": 42,
   357        "members": [
   358          {
   359            "status": "owner",
   360            "public_name": "Alice",
   361            "email": "alice@example.net",
   362            "instance": "alice.example.net"
   363          },
   364          {
   365            "status": "ready",
   366            "name": "Bob",
   367            "email": "bob@example.net"
   368          }
   369        ],
   370        "rules": [
   371          {
   372            "title": "Hawaii",
   373            "doctype": "io.cozy.files",
   374            "values": ["612acf1c-1d72-11e8-b043-ef239d3074dd"],
   375            "add": "sync",
   376            "update": "sync",
   377            "remove": "sync"
   378          }
   379        ]
   380      },
   381      "relationships": {
   382        "shared_docs": {
   383          "data": [
   384            {
   385              "id": "612acf1c-1d72-11e8-b043-ef239d3074dd",
   386              "type": "io.cozy.files"
   387            },
   388            {
   389              "id": "a34528d2-13fb-9482-8d20-bf1972531225",
   390              "type": "io.cozy.files"
   391            }
   392          ]
   393        }
   394      },
   395      "links": {
   396        "self": "/sharings/ce8835a061d0ef68947afe69a0046722"
   397      }
   398    }
   399  }
   400  ```
   401  
   402  ### GET /sharings/news
   403  
   404  It returns the number of shortcuts to a sharing that have not been seen.
   405  
   406  #### Request
   407  
   408  ```http
   409  GET /sharings/news HTTP/1.1
   410  Host: alice.example.net
   411  Accept: application/vnd.api+json
   412  ```
   413  
   414  #### Response
   415  
   416  ```http
   417  HTTP/1.1 200 OK
   418  Content-Type: application/vnd.api+json
   419  ```
   420  
   421  ```json
   422  {
   423    "meta": {
   424      "count": 5
   425    }
   426  }
   427  ```
   428  
   429  ### GET /sharings/doctype/:doctype
   430  
   431  Get information about all the sharings that have a rule for the given doctype.
   432  This includes the content of the rules, the members, as well as the already
   433  shared documents for this sharing.
   434  
   435  #### Request
   436  
   437  ```http
   438  GET /sharings/doctype/io.cozy.files HTTP/1.1
   439  Host: alice.example.net
   440  Accept: application/vnd.api+json
   441  ```
   442  
   443  #### Response
   444  
   445  ```http
   446  HTTP/1.1 200 OK
   447  Content-Type: application/vnd.api+json
   448  ```
   449  
   450  ```json
   451  {
   452    "data": [
   453      {
   454        "type": "io.cozy.sharings",
   455        "id": "ce8835a061d0ef68947afe69a0046722",
   456        "attributes": {
   457          "description": "sharing test",
   458          "preview_path": "/preview-sharing",
   459          "app_slug": "drive",
   460          "owner": true,
   461          "created_at": "2018-01-04T12:35:08Z",
   462          "updated_at": "2018-01-04T13:45:43Z",
   463          "members": [
   464            {
   465              "status": "owner",
   466              "public_name": "Alice",
   467              "email": "alice@example.net",
   468              "instance": "alice.example.net"
   469            },
   470            {
   471              "status": "ready",
   472              "name": "Bob",
   473              "email": "bob@example.net"
   474            }
   475          ],
   476          "rules": [
   477            {
   478              "title": "Hawaii",
   479              "doctype": "io.cozy.files",
   480              "values": ["612acf1c-1d72-11e8-b043-ef239d3074dd"],
   481              "add": "sync",
   482              "update": "sync",
   483              "remove": "sync"
   484            }
   485          ]
   486        },
   487        "meta": {
   488          "rev": "1-4859c6c755143adf0838d225c5e97882"
   489        },
   490        "links": {
   491          "self": "/sharings/ce8835a061d0ef68947afe69a0046722"
   492        },
   493        "relationships": {
   494          "shared_docs": {
   495            "data": [
   496              {
   497                "id": "612acf1c-1d72-11e8-b043-ef239d3074dd",
   498                "type": "io.cozy.files"
   499              },
   500              {
   501                "id": "a34528d2-13fb-9482-8d20-bf1972531225",
   502                "type": "io.cozy.files"
   503              }
   504            ]
   505          }
   506        }
   507      },
   508      {
   509        "type": "io.cozy.sharings",
   510        "id": "b4e58d039c03d01742085de5e505284e",
   511        "attributes": {
   512          "description": "another sharing test",
   513          "preview_path": "/preview-sharing",
   514          "app_slug": "drive",
   515          "owner": true,
   516          "created_at": "2018-02-04T12:35:08Z",
   517          "updated_at": "2018-02-04T13:45:43Z",
   518          "members": [
   519            {
   520              "status": "owner",
   521              "public_name": "Alice",
   522              "email": "alice@example.net",
   523              "instance": "alice.example.net"
   524            },
   525            {
   526              "status": "ready",
   527              "name": "Bob",
   528              "email": "bob@example.net"
   529            }
   530          ],
   531          "rules": [
   532            {
   533              "title": "Singapore",
   534              "doctype": "io.cozy.files",
   535              "values": ["e18e30e2-8eda-1bde-afce-edafc6b1a91b"],
   536              "add": "sync",
   537              "update": "sync",
   538              "remove": "sync"
   539            }
   540          ]
   541        },
   542        "meta": {
   543          "rev": "1-7ac5f1252a0c513186a5d35b1a6fd350"
   544        },
   545        "links": {
   546          "self": "/sharings/b4e58d039c03d01742085de5e505284e"
   547        },
   548        "relationships": {
   549          "shared_docs": {
   550            "data": [
   551              {
   552                "id": "dcc52bee-1277-a6b3-b36f-369ffd81a4ee",
   553                "type": "io.cozy.files"
   554              }
   555            ]
   556          }
   557        }
   558      }
   559    ],
   560    "meta": {
   561      "count": 3
   562    }
   563  }
   564  ```
   565  
   566  ### PUT /sharings/:sharing-id
   567  
   568  The sharer's cozy sends a request to this route on the recipient's cozy to
   569  create a sharing request, with information about the sharing. This request can
   570  be used for two scenarios:
   571  
   572  1. This request will be displayed to the recipient just before its final
   573     acceptation of the sharing, to be sure they know what will be shared.
   574  2. This request will be used to create a shortcut (in that case, a query-string
   575     parameter `shortcut=true&url=...` will be added).
   576  
   577  #### Request
   578  
   579  ```http
   580  PUT /sharings/ce8835a061d0ef68947afe69a0046722 HTTP/1.1
   581  Host: bob.example.net
   582  Content-Type: application/vnd.api+json
   583  ```
   584  
   585  ```json
   586  {
   587    "data": {
   588      "type": "io.cozy.sharings",
   589      "id": "ce8835a061d0ef68947afe69a0046722",
   590      "attributes": {
   591        "description": "sharing test",
   592        "preview_path": "/preview-sharing",
   593        "app_slug": "drive",
   594        "owner": true,
   595        "created_at": "2018-01-04T12:35:08Z",
   596        "updated_at": "2018-01-04T13:45:43Z",
   597        "members": [
   598          {
   599            "status": "owner",
   600            "public_name": "Alice",
   601            "email": "alice@example.net",
   602            "instance": "alice.example.net"
   603          },
   604          {
   605            "status": "mail-not-sent",
   606            "email": "bob@example.net",
   607            "instance": "bob.example.net"
   608          }
   609        ],
   610        "rules": [
   611          {
   612            "title": "Hawaii",
   613            "doctype": "io.cozy.files",
   614            "values": ["612acf1c-1d72-11e8-b043-ef239d3074dd"],
   615            "add": "sync",
   616            "update": "sync",
   617            "remove": "sync"
   618          }
   619        ]
   620      }
   621    }
   622  }
   623  ```
   624  
   625  #### Response
   626  
   627  ```http
   628  HTTP/1.1 200 OK
   629  Content-Type: application/vnd.api+json
   630  ```
   631  
   632  ```json
   633  {
   634    "data": {
   635      "type": "io.cozy.sharings",
   636      "id": "ce8835a061d0ef68947afe69a0046722",
   637      "meta": {
   638        "rev": "1-f579a69a9fa5dd720010a1dbb82320be"
   639      },
   640      "attributes": {
   641        "description": "sharing test",
   642        "preview_path": "/preview-sharing",
   643        "app_slug": "drive",
   644        "owner": true,
   645        "created_at": "2018-01-04T12:35:08Z",
   646        "updated_at": "2018-01-04T13:45:43Z",
   647        "members": [
   648          {
   649            "status": "owner",
   650            "public_name": "Alice",
   651            "email": "alice@example.net",
   652            "instance": "alice.example.net"
   653          },
   654          {
   655            "status": "mail-not-sent",
   656            "name": "Bob",
   657            "email": "bob@example.net",
   658            "instance": "bob.example.net"
   659          }
   660        ],
   661        "rules": [
   662          {
   663            "title": "Hawaii",
   664            "doctype": "io.cozy.files",
   665            "values": ["612acf1c-1d72-11e8-b043-ef239d3074dd"],
   666            "add": "sync",
   667            "update": "sync",
   668            "remove": "sync"
   669          }
   670        ]
   671      },
   672      "links": {
   673        "self": "/sharings/ce8835a061d0ef68947afe69a0046722"
   674      }
   675    }
   676  }
   677  ```
   678  
   679  ### POST /sharings/:sharing-id/answer
   680  
   681  This route is used by the Cozy of a recipient to exchange credentials with the
   682  Cozy of the sharer, after the recipient has accepted a sharing.
   683  
   684  #### Request
   685  
   686  ```http
   687  POST /sharings/ce8835a061d0ef68947afe69a0046722/answer HTTP/1.1
   688  Host: alice.example.net
   689  Content-Type: application/vnd.api+json
   690  ```
   691  
   692  ```json
   693  {
   694    "data": {
   695      "type": "io.cozy.sharings.answer",
   696      "id": "ce8835a061d0ef68947afe69a0046722",
   697      "attributes": {
   698        "public_name": "Bob",
   699        "state": "eiJ3iepoaihohz1Y",
   700        "client": {...},
   701        "access_token": {...}
   702      }
   703    }
   704  }
   705  ```
   706  
   707  When the sharing has a rule for bitwarden organization, the `attributes` also
   708  have a `bitwarden` object with `user_id` and `public_key`, to make it possible
   709  to share documents end to end encrypted.
   710  
   711  #### Response
   712  
   713  ```http
   714  HTTP/1.1 200 OK
   715  Content-Type: application/vnd.api+json
   716  ```
   717  
   718  ```json
   719  {
   720    "data": {
   721      "type": "io.cozy.sharings.answer",
   722      "id": "ce8835a061d0ef68947afe69a0046722",
   723      "attributes": {
   724        "client": {...},
   725        "access_token": {...}
   726      }
   727    }
   728  }
   729  ```
   730  
   731  ### POST /sharings/:sharing-id/public-key
   732  
   733  This route can be used by a sharing member to send their new public key after
   734  they have chosen their password for the first time (delegated authentication).
   735  
   736  #### Request
   737  
   738  ```http
   739  POST /sharings/ce8835a061d0ef68947afe69a0046722/public-key HTTP/1.1
   740  Host: alice.example.net
   741  Content-Type: application/vnd.api+json
   742  Authorization: Bearer ...
   743  ```
   744  
   745  ```json
   746  {
   747    "data": {
   748      "type": "io.cozy.sharings.answer",
   749      "id": "ce8835a061d0ef68947afe69a0046722",
   750      "attributes": {
   751        "bitwarden": {
   752          "user_id": "0dc76ad9b1cf3a979b916b3155001830",
   753          "public_key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1wboB9QutvRKGswphAre6xi4boYxSw4IjXqXDTV297Cq/MB2cBklj+sMmRQNTkU266HFSTGp3jDVcegAsHMpVVlTKZnWW+gSP2+vSyGs9NUvG8JfLday1iuOntHJQkfYiZ7+BfBYFtx6iWRnbnegickyoS7PWibLP5lmEzZnFtrGcRT8urSfN61qlOVD1u+eqtif5tabdU6eyNWUMLCQYgtaGb1nNht/xDgbpBc3b2XbEF0tBJRFR5571EH1h//Ae7IT+pYuBZB9BoPAHj4fhQm3++oNjemUJbaVi0dM4KNfQ89z1lBBCh5lxAGPlpOjapN0qGPgSov8B9U+qXlmzQIDAQAB"
   754        }
   755      }
   756    }
   757  }
   758  ```
   759  
   760  #### Response
   761  
   762  ```http
   763  HTTP/1.1 204 No Content
   764  ```
   765  
   766  ### POST /sharings/:sharing-id/recipients
   767  
   768  This route allows the sharer to add new recipients (and groups of recipients)
   769  to a sharing. It can also be used by a recipient when the sharing has
   770  `open_sharing` set to true if the recipient doesn't have the `read_only` flag.
   771  
   772  #### Request
   773  
   774  ```http
   775  POST /sharings/ce8835a061d0ef68947afe69a0046722/recipients HTTP/1.1
   776  Host: alice.example.net
   777  Content-Type: application/vnd.api+json
   778  ```
   779  
   780  ```json
   781  {
   782    "data": {
   783      "type": "io.cozy.sharings",
   784      "id": "ce8835a061d0ef68947afe69a0046722",
   785      "relationships": {
   786        "recipients": {
   787          "data": [
   788            {
   789              "id": "ce7b1dfbd460039159f228298a29b2aa",
   790              "type": "io.cozy.contacts"
   791            }
   792          ]
   793        },
   794        "read_only_recipients": {
   795          "data": [
   796            {
   797              "id": "e15384a1223ae2501cc1c4fa94008ea0",
   798              "type": "io.cozy.contacts"
   799            }
   800          ]
   801        }
   802      }
   803    }
   804  }
   805  ```
   806  
   807  #### Response
   808  
   809  ```http
   810  HTTP/1.1 200 OK
   811  Content-Type: application/vnd.api+json
   812  ```
   813  
   814  ```json
   815  {
   816    "data": {
   817      "type": "io.cozy.sharings",
   818      "id": "ce8835a061d0ef68947afe69a0046722",
   819      "meta": {
   820        "rev": "1-4859c6c755143adf0838d225c5e97882"
   821      },
   822      "attributes": {
   823        "description": "sharing test",
   824        "preview_path": "/preview-sharing",
   825        "app_slug": "drive",
   826        "owner": true,
   827        "created_at": "2018-01-04T12:35:08Z",
   828        "updated_at": "2018-01-04T13:45:43Z",
   829        "members": [
   830          {
   831            "status": "owner",
   832            "public_name": "Alice",
   833            "email": "alice@example.net",
   834            "instance": "alice.example.net"
   835          },
   836          {
   837            "status": "ready",
   838            "name": "Bob",
   839            "public_name": "Bob",
   840            "email": "bob@example.net"
   841          },
   842          {
   843            "status": "pending",
   844            "name": "Charlie",
   845            "email": "charlie@example.net"
   846          },
   847          {
   848            "status": "pending",
   849            "name": "Dave",
   850            "email": "dave@example.net",
   851            "read_only": true
   852          }
   853        ],
   854        "rules": [
   855          {
   856            "title": "Hawaii",
   857            "doctype": "io.cozy.files",
   858            "values": ["612acf1c-1d72-11e8-b043-ef239d3074dd"],
   859            "add": "sync",
   860            "update": "sync",
   861            "remove": "sync"
   862          }
   863        ]
   864      },
   865      "relationships": {
   866        "shared_docs": {
   867          "data": [
   868            {
   869              "id": "612acf1c-1d72-11e8-b043-ef239d3074dd",
   870              "type": "io.cozy.files"
   871            },
   872            {
   873              "id": "a34528d2-13fb-9482-8d20-bf1972531225",
   874              "type": "io.cozy.files"
   875            }
   876          ]
   877        }
   878      },
   879      "links": {
   880        "self": "/sharings/ce8835a061d0ef68947afe69a0046722"
   881      }
   882    }
   883  }
   884  ```
   885  
   886  ### POST /sharings/:sharing-id/recipients/delegated
   887  
   888  This is an internal route for the stack. It is called by the recipient cozy on
   889  the owner cozy to add recipients and groups to the sharing (`open_sharing:
   890  true` only). Data for direct recipients should contain an email address but if
   891  it is not known, an instance URL can also be provided.
   892  
   893  #### Request
   894  
   895  ```http
   896  POST /sharings/ce8835a061d0ef68947afe69a0046722/recipients/delegated HTTP/1.1
   897  Host: alice.example.net
   898  Content-Type: application/vnd.api+json
   899  ```
   900  
   901  ```json
   902  {
   903    "data": {
   904      "type": "io.cozy.sharings",
   905      "id": "ce8835a061d0ef68947afe69a0046722",
   906      "relationships": {
   907        "recipients": {
   908          "data": [
   909            {
   910              "email": "dave@example.net"
   911            }
   912          ]
   913        },
   914        "groups": {
   915          "data": [
   916            {
   917              "id": "b57cd790b2f4013c3ced18c04daba326",
   918              "name": "Dance",
   919              "addedBy": 1
   920            }
   921          ]
   922        }
   923      }
   924    }
   925  }
   926  ```
   927  
   928  #### Response
   929  
   930  ```http
   931  HTTP/1.1 200 OK
   932  Content-Type: application/json
   933  ```
   934  
   935  ```json
   936  {
   937    "dave@example.net": "uS6wN7fTYaLZ-GdC_P6UWA"
   938  }
   939  ```
   940  
   941  ### POST /sharings/:sharing-id/members/:index/invitation
   942  
   943  This is an internal route for the stack. It is called by the recipient cozy on
   944  the owner cozy to send an invitation.
   945  
   946  #### Request
   947  
   948  ```http
   949  POST /sharings/ce8835a061d0ef68947afe69a0046722/members/4/invitation HTTP/1.1
   950  Host: alice.example.net
   951  Content-Type: application/vnd.api+json
   952  ```
   953  
   954  ```json
   955  {
   956    "data": {
   957      "type": "io.cozy.sharings.members",
   958      "attributes": {
   959        "email": "diana@example.net"
   960      }
   961    }
   962  }
   963  ```
   964  
   965  #### Response
   966  
   967  ```http
   968  HTTP/1.1 200 OK
   969  Content-Type: application/json
   970  ```
   971  
   972  ```json
   973  {
   974    "diana@example.net": "uS6wN7fTYaLZ-GdC_P6UWA"
   975  }
   976  ```
   977  
   978  ### DELETE /sharings/:sharing-id/groups/:group-index/:member-index
   979  
   980  This is an internal route for the stack. It is called by the recipient cozy on
   981  the owner cozy to remove a member of a sharing from a group.
   982  
   983  #### Request
   984  
   985  ```http
   986  DELETE /sharings/ce8835a061d0ef68947afe69a0046722/groups/0/1 HTTP/1.1
   987  Host: alice.example.net
   988  ```
   989  
   990  #### Response
   991  
   992  ```http
   993  HTTP/1.1 204 No Content
   994  ```
   995  
   996  ### PUT /sharings/:sharing-id/recipients
   997  
   998  This internal route is used to update the list of members (their states, emails
   999  and names) and the list of groups on the recipients cozy. The token used for
  1000  this route can be the access token for a sharing where synchronization is
  1001  active, or the sharecode for a member who has only a shortcut to the sharing on
  1002  their Cozy instance.
  1003  
  1004  #### Request
  1005  
  1006  ```http
  1007  PUT /sharings/ce8835a061d0ef68947afe69a0046722/recipients HTTP/1.1
  1008  Host: bob.example.net
  1009  Content-Type: application/vnd.api+json
  1010  ```
  1011  
  1012  ```json
  1013  {
  1014    "data": [
  1015      {
  1016        "status": "owner",
  1017        "public_name": "Alice",
  1018        "email": "alice@example.net",
  1019        "instance": "alice.example.net"
  1020      },
  1021      {
  1022        "status": "ready",
  1023        "name": "Bob",
  1024        "public_name": "Bob",
  1025        "email": "bob@example.net"
  1026      },
  1027      {
  1028        "status": "ready",
  1029        "name": "Charlie",
  1030        "public_name": "Charlie",
  1031        "email": "charlie@example.net"
  1032      },
  1033      {
  1034        "status": "pending",
  1035        "name": "Dave",
  1036        "email": "dave@example.net",
  1037        "read_only": true
  1038      }
  1039    ],
  1040    "included": [
  1041      {
  1042        "id": "51bbc980acb0013cb5f618c04daba326",
  1043        "name": "G. people",
  1044        "addedBy": 0
  1045      }
  1046    ]
  1047  }
  1048  ```
  1049  
  1050  #### Response
  1051  
  1052  ```http
  1053  HTTP/1.1 204 No Content
  1054  ```
  1055  
  1056  ### GET /sharings/:sharing-id/recipients/:index/avatar
  1057  
  1058  This route can be used to get an image that shows the avatar of a member of
  1059  this sharing. No permission is required to use this route, you just need to
  1060  know the sharing-id to use it. If no image has been chosen, a fallback will be
  1061  used, depending of the `fallback` parameter in the query-string:
  1062  
  1063  - `initials`: a generated image with the initials of the owner's public name. This is the default behavior.
  1064  - `404`: just a 404 - Not found error.
  1065  
  1066  If the `initials` fallback is used and the member has not yet seen the sharing,
  1067  the background of the image will be grey.
  1068  
  1069  **Note**: 0 for the index means the sharer.
  1070  
  1071  #### Request
  1072  
  1073  ```http
  1074  GET /sharings/ce8835a061d0ef68947afe69a0046722/recipients/2/avatar HTTP/1.1
  1075  Host: bob.example.net
  1076  Accept: image/*
  1077  ```
  1078  
  1079  ### POST /sharings/:sharing-id/recipients/:index/readonly
  1080  
  1081  This route is used to add the read-only flag on a recipient of a sharing.
  1082  
  1083  **Note**: 0 is not accepted for `index`, as it is the sharer him-self.
  1084  
  1085  ##### Request
  1086  
  1087  ```http
  1088  POST /sharings/ce8835a061d0ef68947afe69a0046722/recipients/3/readonly HTTP/1.1
  1089  Host: alice.example.net
  1090  ```
  1091  
  1092  #### Response
  1093  
  1094  ```http
  1095  HTTP/1.1 204 No Content
  1096  ```
  1097  
  1098  ### POST /sharings/:sharing-id/recipients/self/readonly
  1099  
  1100  This is an internal route for the stack. It's used to inform the recipient's
  1101  cozy that it is no longer in read-write mode. It also gives it an access token
  1102  with a short validity (1 hour) to let it try to synchronize its last changes
  1103  before going to read-only mode.
  1104  
  1105  #### Request
  1106  
  1107  ```http
  1108  POST /sharings/ce8835a061d0ef68947afe69a0046722/recipients/self/readonly HTTP/1.1
  1109  Host: bob.example.net
  1110  Authorization: Bearer ...
  1111  Content-Type: application/vnd.api+json
  1112  ```
  1113  
  1114  ```json
  1115  {
  1116    "data": {
  1117      "type": "io.cozy.sharings.answer",
  1118      "id": "4dadbcae3f2d7a982e1b308eea000751",
  1119      "attributes": {
  1120        "client": {...},
  1121        "access_token": {...}
  1122      }
  1123    }
  1124  }
  1125  ```
  1126  
  1127  #### Response
  1128  
  1129  ```http
  1130  HTTP/1.1 204 No Content
  1131  ```
  1132  
  1133  ### DELETE /sharings/:sharing-id/recipients/:index/readonly
  1134  
  1135  This route is used to remove the read-only flag on a recipient of a sharing.
  1136  
  1137  **Note**: 0 is not accepted for `index`, as it is the sharer him-self.
  1138  
  1139  ##### Request
  1140  
  1141  ```http
  1142  DELETE /sharings/ce8835a061d0ef68947afe69a0046722/recipients/3/readonly HTTP/1.1
  1143  Host: alice.example.net
  1144  ```
  1145  
  1146  #### Response
  1147  
  1148  ```http
  1149  HTTP/1.1 204 No Content
  1150  ```
  1151  
  1152  ### DELETE /sharings/:sharing-id/recipients/self/readonly
  1153  
  1154  This is an internal route for the stack. It's used to inform the recipient's
  1155  cozy that it is no longer in read-only mode, and to give it the credentials for
  1156  sending its updates.
  1157  
  1158  #### Request
  1159  
  1160  ```http
  1161  DELETE /sharings/ce8835a061d0ef68947afe69a0046722/recipients/self/readonly HTTP/1.1
  1162  Host: bob.example.net
  1163  Authorization: Bearer ...
  1164  Content-Type: application/vnd.api+json
  1165  ```
  1166  
  1167  ```json
  1168  {
  1169    "data": {
  1170      "type": "io.cozy.sharings.answer",
  1171      "id": "4dadbcae3f2d7a982e1b308eea000751",
  1172      "attributes": {
  1173        "client": {...},
  1174        "access_token": {...}
  1175      }
  1176    }
  1177  }
  1178  ```
  1179  
  1180  #### Response
  1181  
  1182  ```http
  1183  HTTP/1.1 204 No Content
  1184  ```
  1185  
  1186  ### DELETE /sharings/:sharing-id/recipients
  1187  
  1188  This route is used by an application on the owner's cozy to revoke the sharing
  1189  for all the members. After that, the sharing active flag will be false, the
  1190  credentials for all members will be revoked, the members that have accepted the
  1191  sharing will have their cozy informed that the sharing has been revoked, and
  1192  pending members can no longer accept this sharing.
  1193  
  1194  #### Request
  1195  
  1196  ```http
  1197  DELETE /sharings/ce8835a061d0ef68947afe69a0046722/recipients HTTP/1.1
  1198  Host: alice.example.net
  1199  ```
  1200  
  1201  #### Response
  1202  
  1203  ```http
  1204  HTTP/1.1 204 No Content
  1205  ```
  1206  
  1207  ### DELETE /sharings/:sharing-id/recipients/:index
  1208  
  1209  This route can be only be called on the cozy instance of the sharer to revoke
  1210  only one recipient of the sharing. The parameter is the index of this recipient 
  1211  in the `members` array of the sharing. 
  1212  The status for this member will be set to `revoked`, its cozy will be informed of the
  1213  revokation, and the credentials for this cozy will be deleted.
  1214  
  1215  **Note**: 0 is not accepted for `index`, as it is the sharer him-self.
  1216  
  1217  #### Request
  1218  
  1219  ```http
  1220  DELETE /sharings/ce8835a061d0ef68947afe69a0046722/recipients/1 HTTP/1.1
  1221  Host: alice.example.net
  1222  ```
  1223  
  1224  #### Response
  1225  
  1226  ```http
  1227  HTTP/1.1 204 No Content
  1228  ```
  1229  
  1230  ### DELETE /sharings/:sharing-id/groups/:index
  1231  
  1232  This route can be only be called on the cozy instance of the sharer to revoke a
  1233  group of the sharing. The parameter is the index of this recipient in the
  1234  `groups` array of the sharing. The `removed` property for this group will be
  1235  set to `true`, and it will revoke the members of this group unless they are
  1236  still part of the sharing via another group or as direct recipients.
  1237  
  1238  #### Request
  1239  
  1240  ```http
  1241  DELETE /sharings/ce8835a061d0ef68947afe69a0046722/groups/0 HTTP/1.1
  1242  Host: alice.example.net
  1243  ```
  1244  
  1245  #### Response
  1246  
  1247  ```http
  1248  HTTP/1.1 204 No Content
  1249  ```
  1250  
  1251  ### DELETE /sharings/:sharing-id/recipients/self
  1252  
  1253  This route can be used by an application in the cozy of a recipient to remove it
  1254  from the sharing.
  1255  
  1256  #### Request
  1257  
  1258  ```http
  1259  DELETE /sharings/ce8835a061d0ef68947afe69a0046722/recipients/self HTTP/1.1
  1260  Host: bob.example.net
  1261  ```
  1262  
  1263  #### Response
  1264  
  1265  ```http
  1266  HTTP/1.1 204 No Content
  1267  ```
  1268  
  1269  ### DELETE /sharings/:sharing-id
  1270  
  1271  This is an internal route used by the cozy of the sharing's owner to inform a
  1272  recipient's cozy that it was revoked.
  1273  
  1274  #### Request
  1275  
  1276  ```http
  1277  DELETE /sharings/ce8835a061d0ef68947afe69a0046722 HTTP/1.1
  1278  Host: bob.example.net
  1279  ```
  1280  
  1281  #### Response
  1282  
  1283  ```http
  1284  HTTP/1.1 204 No Content
  1285  ```
  1286  
  1287  ### DELETE /sharings/:sharing-id/answer
  1288  
  1289  This is an internal route used by a recipient's cozy to inform the owner's cozy
  1290  that this recipient no longer wants to be part of the sharing.
  1291  
  1292  #### Request
  1293  
  1294  ```http
  1295  DELETE /sharings/ce8835a061d0ef68947afe69a0046722/answer HTTP/1.1
  1296  Host: alice.example.net
  1297  ```
  1298  
  1299  #### Response
  1300  
  1301  ```http
  1302  HTTP/1.1 204 No Content
  1303  ```
  1304  
  1305  ### POST /sharings/:sharing-id/recipients/self/moved
  1306  
  1307  This route can be used to inform that a Cozy has been moved to a new address.
  1308  
  1309  #### Request
  1310  
  1311  ```http
  1312  POST /sharings/ce8835a061d0ef68947afe69a0046722/recipients/self/moved HTTP/1.1
  1313  Host: bob.example.net
  1314  Authorization: Bearer ...
  1315  Content-Type: application/vnd.api+json
  1316  ```
  1317  
  1318  ```json
  1319  {
  1320    "data": {
  1321      "type": "io.cozy.sharings.moved",
  1322      "id": "ce8835a061d0ef68947afe69a0046722",
  1323      "attributes": {
  1324        "new_instance": "https://alice.newcozy.example",
  1325        "access_token": "xxx",
  1326        "refresh_token": "xxx"
  1327      }
  1328    }
  1329  }
  1330  ```
  1331  
  1332  #### Response
  1333  
  1334  ```http
  1335  HTTP/1.1 204 No Content
  1336  ```
  1337  
  1338  ### POST /sharings/:sharing-id/\_revs_diff
  1339  
  1340  This endpoint is used by the sharing replicator of the stack to know which
  1341  documents must be sent to the other cozy. It is inspired by
  1342  http://docs.couchdb.org/en/stable/api/database/misc.html#db-revs-diff.
  1343  
  1344  #### Request
  1345  
  1346  ```http
  1347  POST /sharings/ce8835a061d0ef68947afe69a0046722/_revs_diff HTTP/1.1
  1348  Host: bob.example.net
  1349  Accept: application/json
  1350  Content-Type: application/json
  1351  Authorization: Bearer ...
  1352  ```
  1353  
  1354  ```json
  1355  {
  1356    "io.cozy.files/29631902-2cec-11e8-860d-435b24c2cc58": [
  1357      "2-4a7e4ae49c4366eaed8edeaea8f784ad"
  1358    ],
  1359    "io.cozy.files/44f5752a-2cec-11e8-b227-abfc3cfd4b6e": [
  1360      "4-2ee767305024673cfb3f5af037cd2729",
  1361      "4-efc54218773c6acd910e2e97fea2a608"
  1362    ]
  1363  }
  1364  ```
  1365  
  1366  #### Response
  1367  
  1368  ```http
  1369  HTTP/1.1 200 OK
  1370  Content-Type: application/json
  1371  ```
  1372  
  1373  ```json
  1374  {
  1375    "io.cozy.files/44f5752a-2cec-11e8-b227-abfc3cfd4b6e": {
  1376      "missing": ["4-2ee767305024673cfb3f5af037cd2729"],
  1377      "possible_ancestors": ["3-753875d51501a6b1883a9d62b4d33f91"]
  1378    }
  1379  }
  1380  ```
  1381  
  1382  ### POST /sharings/:sharing-id/\_bulk_docs
  1383  
  1384  This endpoint is used by the sharing replicator of the stack to send documents
  1385  in a bulk to the other cozy. It is inspired by
  1386  http://docs.couchdb.org/en/stable/api/database/bulk-api.html#db-bulk-docs.
  1387  
  1388  **Note**: we force `new_edits` to `false`.
  1389  
  1390  #### Request
  1391  
  1392  ```http
  1393  POST /sharings/ce8835a061d0ef68947afe69a0046722/_bulk_docs HTTP/1.1
  1394  Host: bob.example.net
  1395  Accept: application/json
  1396  Content-Type: application/json
  1397  Authorization: Bearer ...
  1398  ```
  1399  
  1400  ```json
  1401  {
  1402    "io.cozy.files": [
  1403      {
  1404        "_id": "44f5752a-2cec-11e8-b227-abfc3cfd4b6e",
  1405        "_rev": "4-2ee767305024673cfb3f5af037cd2729",
  1406        "_revisions": {
  1407          "start": 4,
  1408          "ids": [
  1409            "2ee767305024673cfb3f5af037cd2729",
  1410            "753875d51501a6b1883a9d62b4d33f91"
  1411          ]
  1412        }
  1413      }
  1414    ]
  1415  }
  1416  ```
  1417  
  1418  #### Response
  1419  
  1420  ```http
  1421  HTTP/1.1 200 OK
  1422  Content-Type: application/json
  1423  ```
  1424  
  1425  ```json
  1426  []
  1427  ```
  1428  
  1429  ### GET /sharings/:sharing-id/io.cozy.files/:file-id
  1430  
  1431  This is an internal endpoint used by a stack to get information about a folder.
  1432  It is used when a cozy sent to another cozy a file or folder inside a folder
  1433  that was trashed (and trash was emptied): the recipient does no longer have
  1434  information about the parent directory. To resolve the conflict, it recreates
  1435  the missing parent directory by asking the other cozy informations about it.
  1436  
  1437  #### Request
  1438  
  1439  ```http
  1440  GET /sharings/ce8835a061d0ef68947afe69a0046722/io.cozy.files/6d245d072be5522bd3a6f273dd000c65 HTTP/1.1
  1441  Host: alice.example.net
  1442  Accept: application/json
  1443  Authorization: Bearer ...
  1444  ```
  1445  
  1446  #### Response
  1447  
  1448  ```http
  1449  HTTP/1.1 200 OK
  1450  Content-Type: application/json
  1451  ```
  1452  
  1453  ```json
  1454  {
  1455    "_id": "6d245d072be5522bd3a6f273dd000c65",
  1456    "_rev": "1-de4ec176ffa9ddafe8bdcc739dc60fed",
  1457    "type": "directory",
  1458    "name": "phone",
  1459    "dir_id": "6d245d072be5522bd3a6f273dd007396",
  1460    "created_at": "2016-09-19T12:35:08Z",
  1461    "updated_at": "2016-09-19T12:35:08Z",
  1462    "tags": ["bills"]
  1463  }
  1464  ```
  1465  
  1466  ### PUT /sharings/:sharing-id/io.cozy.files/:file-id/metadata
  1467  
  1468  This is an internal endpoint used by a stack to send the new metadata about a
  1469  file that has changed.
  1470  
  1471  #### Request
  1472  
  1473  ```http
  1474  PUT /sharings/ce8835a061d0ef68947afe69a0046722/io.cozy.files/0c1116b028c6ae6f5cdafb949c088265/metadata HTTP/1.1
  1475  Host: bob.example.net
  1476  Accept: application/json
  1477  Content-Type: application/json
  1478  Authorization: Bearer ...
  1479  ```
  1480  
  1481  ```json
  1482  {
  1483    "_id": "4b24ab130b2538b7b444fc65430198ad",
  1484    "_rev": "1-356bf77c03baa1da851a2be1f06aba81",
  1485    "_revisions": {
  1486      "start": 1,
  1487      "ids": ["356bf77c03baa1da851a2be1f06aba81"]
  1488    },
  1489    "type": "file",
  1490    "name": "cloudy.jpg",
  1491    "dir_id": "4b24ab130b2538b7b444fc65430188cd",
  1492    "created_at": "2018-01-03T16:10:36.885807013+01:00",
  1493    "updated_at": "2018-01-03T16:10:36.885807013+01:00",
  1494    "size": "84980",
  1495    "md5sum": "SuRJOiD/QPwDUpKpQujcVA==",
  1496    "mime": "image/jpeg",
  1497    "class": "image",
  1498    "executable": false,
  1499    "trashed": false,
  1500    "tags": [],
  1501    "metadata": {
  1502      "datetime": "2018-01-03T16:10:36.89118949+01:00",
  1503      "extractor_version": 2,
  1504      "height": 1200,
  1505      "width": 1600
  1506    }
  1507  }
  1508  ```
  1509  
  1510  #### Response
  1511  
  1512  If only the metadata has changed (not the content), the response will be a 204:
  1513  
  1514  ```http
  1515  HTTP/1.1 204 No Content
  1516  ```
  1517  
  1518  Else, the content will need to be uploaded:
  1519  
  1520  ```
  1521  HTTP/1.1 200 OK
  1522  Content-Type: application/json
  1523  ```
  1524  
  1525  ```json
  1526  {
  1527    "key": "dcd478c6-46cf-11e8-9c3f-535468cbce7b"
  1528  }
  1529  ```
  1530  
  1531  ### PUT /sharings/:sharing-id/io.cozy.files/:key
  1532  
  1533  Upload the content of a file (new file or its content has changed since the last
  1534  synchronization).
  1535  
  1536  #### Request
  1537  
  1538  ```http
  1539  PUT /sharings/ce8835a061d0ef68947afe69a0046722/io.cozy.files/dcd478c6-46cf-11e8-9c3f-535468cbce7b HTTP/1.1
  1540  Host: bob.example.net
  1541  Content-Type: image/jpeg
  1542  Authorization: Bearer ...
  1543  ```
  1544  
  1545  #### Response
  1546  
  1547  ```http
  1548  HTTP/1.1 204 No Content
  1549  ```
  1550  
  1551  ### POST /sharings/:sharing-id/reupload
  1552  
  1553  This is an internal route for the stack. It is called when the disk quota of an
  1554  instance is increased to ask for the others instances on this sharing to try to
  1555  reupload files without waiting for the normal retry period.
  1556  
  1557  #### Request
  1558  
  1559  ```http
  1560  POST /sharings/ce8835a061d0ef68947afe69a0046722/reupload HTTP/1.1
  1561  Host: bob.example.net
  1562  Authorization: Bearer ...
  1563  ```
  1564  
  1565  #### Response
  1566  
  1567  ```http
  1568  HTTP/1.1 204 No Content
  1569  ```
  1570  
  1571  ### DELETE /sharings/:sharing-id/initial
  1572  
  1573  This internal route is used by the sharer to inform a recipient's cozy that the
  1574  initial sync is finished.
  1575  
  1576  ```http
  1577  DELETE /sharings/ce8835a061d0ef68947afe69a0046722/initial HTTP/1.1
  1578  Host: bob.example.net
  1579  Authorization: Bearer ...
  1580  ```
  1581  
  1582  #### Response
  1583  
  1584  ```http
  1585  HTTP/1.1 204 No Content
  1586  ```
  1587  
  1588  ## Real-time via websockets
  1589  
  1590  You can subscribe to the [realtime](realtime.md) API for the normal doctypes,
  1591  but also for a special `io.cozy.sharings.initial_sync` doctype. For this
  1592  doctype, you can give the id of a sharing and you will be notified when a file
  1593  will be received during the initial synchronisation (`UPDATED`), and when the
  1594  sync will be done (`DELETED`).
  1595  
  1596  ### Example
  1597  
  1598  ```
  1599  client > {"method": "AUTH",
  1600            "payload": "xxAppOrAuthTokenxx="}
  1601  client > {"method": "SUBSCRIBE",
  1602            "payload": {"type": "io.cozy.sharings.initial_sync", "id": "ce8835a061d0ef68947afe69a0046722"}}
  1603  server > {"event": "UPDATED",
  1604            "payload": {"id": "ce8835a061d0ef68947afe69a0046722", "type": "io.cozy.sharings.initial_sync", "doc": {"count": 12}}}
  1605  server > {"event": "UPDATED",
  1606            "payload": {"id": "ce8835a061d0ef68947afe69a0046722", "type": "io.cozy.sharings.initial_sync", "doc": {"count": 13}}}
  1607  server > {"event": "DELETED",
  1608            "payload": {"id": "ce8835a061d0ef68947afe69a0046722", "type": "io.cozy.sharings.initial_sync"}}
  1609  ```