Skip to the content.

Doctypes

Doctypes represent different types of data. Their primary use is for permissions: an app or konnector will request permissions for one or several doctypes and will not be able to access other doctypes.

!!! note Example: A banking application requests permissions for banking doctypes (io.cozy.bank.accounts, io.cozy.bank.operations etc..) but cannot access files (io.cozy.files). This ensure the segregation and security of your data.

In this repository, every (known) doctype and the fields that they contain is described. If you feel the need for another doctype, feel free to open a PR with the description and role of your doctype.

Cozy doctypes

Technical doctypes

Remote doctypes

This repository is where the declaration of remote doctypes is done. Read more about remote doctypes in the cozy stack repository.

External doctypes

Generic model

Relationships

Relations between documents are under a relationships object at the root of the document. Relations are referenced by their names.

Each relation is an object with a data property containing either null, one reference or an array of references.

A reference is an object containing at least a _type with the name of the referenced doctype and an _id with the id of the referenced document inside its doctype.

{
  "_id": "mobydick",
  "relationships": {
    "authors": {
      "data": [{ "_id": "hermanmelville", "_type": "io.cozy.contacts" }]
    }
  }
}

External relationships

Relationships that reference a document that lives outside the couchdb of the user will have a _type in a different namespace than io.cozy.*, and will have an additional _protocol field.

At the moment the only available external relationship is bitwarden with the following format:

{
  "_id": "secretsafe",
  "relationships": {
    "vaultCipher": {
      "data": [{ "_id": "123abc", "_type": "com.bitwarden.ciphers", "_protocol": "bitwarden" }]
    }
  }
}

Relationships with metadata

A relationship can store additional information, in the metadata attribute. For instance, see the contracts relationship for the accounts.

"relationships": {
  "contracts": {
    "data": [
      {
        "_id": "77b662b903f1bac7a78cf8cc12806479",
        "_type": "io.cozy.bank.accounts",
        "metadata": {
          "deletedByVendor": false,
          "imported": true,
          "label": "Compte chèque",
          "vendorId": "1337"
        }
      }
    ]
  }
}

Document metadata

We distinguish three levels of attributes:

  1. The data (e.g. a list of songs from a playlist)
  2. The metadata about the data (e.g. the creation date of the playlist itself)
  3. The metadata of the cozy document (e.g. the creation date of the cozy document describing the playlist).

The third level is described by an object named cozyMetadata at the root of the document. This object structure is common to all Cozy doctypes.

The expected cozyMetadata attributes are the following:

ℹ️ All these attributes are optional and taken care by the apps modifying the document. Unless specified otherwise in the documentation of the doctype, all these attributes may not be present or may have a null value.

ℹ️ For doctypes protected by the stack such as io.cozy.files, any non-expected attribute in cozyMetadata will be refused by the stack.

{
  "_id": "xxxx",
  "cozyMetadata": {
    "doctypeVersion": 4,
    "metadataVersion": 1,
    "createdAt": "xxxxx",
    "createdByApp": "xxxx",
    "createdByAppVersion": "xxxx",
    "updatedAt": "xxxxx",
    "updatedByApps": [
      {
        "slug": "xxxxx",
        "date": "xxxxx",
        "version": 3
      }
    ],
    "sourceAccount": "xxxxx",
    "sourceAccountIdentifier": "test@mail.fr"
  }
}

Date format

Date should be formatted in ISO8601 :