Create Share

Create a share record for data exchange between qid accounts

POST /di/share

Body

PropertyTypeRequiredDescription
templateIdstringYesTemplate ID for the share. Must be a valid ObjectId.
otherFieldsFields[]NoAdditional form fields. Stored exactly as sent.
participantsParticipant[]YesAccounts involved in the share. At least one participant must have the organiser role.
statusstringYesInitial share status: open or completed. closed is not accepted on create (the API returns 500).

Example request

curl --request POST 'https://api.qidpro.xyz/di/share' \
  --header 'Authorization: Bearer your-secret-key' \
  --header 'tokenId: your-token-id' \
  --header 'Content-Type: application/json' \
  --data '{
    "templateId": "669d25bf4be6e965914a9e3e",
    "otherFields": [
      {
        "label": "Purpose of Visit",
        "name": "purpose_of_visit",
        "value": "Work"
      }
    ],
    "status": "open",
    "participants": [
      {
        "roles": ["organiser", "admin"],
        "account_id": "6627c83c122f76583c42ff10",
        "accountType": "organisation",
        "accountSnapshot": {
          "name": "Test Adventures",
          "displayPictureUrl": "c103be9234.jpeg"
        },
        "analytics": {
          "gender": "male",
          "age": 23,
          "zipCode": "110030"
        }
      },
      {
        "roles": ["sharer", "admin"],
        "account_id": "65dea5868910b6f5957a0fb5",
        "accountType": "user",
        "accountSnapshot": {
          "name": "Rahul Sharma"
        },
        "sharedDocumentsIds": [
          "65df7d42fdfc8d3689057d8e"
        ]
      }
    ]
  }'

Only templateId, status and participants (with roles, account_id and accountType) are needed. otherFields, accountSnapshot, analytics and sharedDocumentsIds can be left out.

Participant fields

FieldDescription
rolesArray of roles: organiser, admin, sharer
account_idqid account ID. Must be a valid ObjectId.
accountTypeuser or organisation
accountSnapshotSnapshot of account details. Stored exactly as sent; the API does not fill it in from the account.
sharedDocumentsIdsDocument IDs shared by this participant
analyticsOptional analytics metadata (gender, age, zipCode)

Example response

Returns 201 Created with the new share. The share ID is in _id.

{
  "deleteTime": null,
  "schemaVersion": "3",
  "participants": [
    {
      "roles": ["organiser", "admin"],
      "account_id": "6627c83c122f76583c42ff10",
      "accountType": "organisation",
      "accountSnapshot": {
        "name": "Test Adventures",
        "displayPictureUrl": "c103be9234.jpeg"
      },
      "analytics": {
        "gender": "male",
        "age": 23,
        "zipCode": "110030"
      }
    },
    {
      "roles": ["sharer", "admin"],
      "account_id": "65dea5868910b6f5957a0fb5",
      "accountType": "user",
      "accountSnapshot": {
        "name": "Rahul Sharma"
      },
      "sharedDocumentsIds": ["65df7d42fdfc8d3689057d8e"]
    }
  ],
  "otherFields": [
    {
      "label": "Purpose of Visit",
      "name": "purpose_of_visit",
      "value": "Work"
    }
  ],
  "template": "669d25bf4be6e965914a9e3e",
  "isQuotaLocked": false,
  "status": "open",
  "agreements": [],
  "updateLogs": [
    {
      "remark": "Share Started",
      "updatedByAccount_id": "6627c83c122f76583c42ff10",
      "updatedByAccountType": "organisation",
      "updatedByAccountSnapshot": {
        "name": "Cloud API - Test Key"
      },
      "updateTime": "2026-03-09T09:39:44.886Z"
    }
  ],
  "isPublicJoin": false,
  "collectionRequestId": null,
  "automations": [],
  "webhookUrl": null,
  "webhookSecret": null,
  "webhookIdentifier": null,
  "_id": "69ae9560ba7f6726e85f60ca",
  "createTime": "2026-03-09T09:39:44.886Z",
  "lastUpdateTime": "2026-03-09T09:39:44.886Z",
  "__v": 0
}
PropertyTypeDescription
_idstringShare ID. Use it with Read Share.
deleteTimestring | nullDeletion time, null for active shares
schemaVersionstringShare record schema version
participantsParticipant[]Participants as sent in the request
otherFieldsFields[]Form fields as sent in the request ([] if omitted)
templatestringTemplate ID. On create this is the plain ID; Read Share returns the template object.
isQuotaLockedbooleanWhether the share is quota locked
statusstringShare status
agreementsobject[]Accepted agreements ([] on create)
updateLogsobject[]Activity log. The first entry is Share Started, logged against the organisation that owns the API key.
isPublicJoinbooleanWhether the share can be joined publicly
collectionRequestIdstring | nullLinked collection request, null for shares created directly
automationsstring[]Automations enabled for the share
webhookUrlstring | nullWebhook URL for the share
webhookSecretstring | nullWebhook secret
webhookIdentifierstring | nullWebhook identifier
createTimestringCreation time (ISO 8601)
lastUpdateTimestringLast update time (ISO 8601)
__vnumberRecord version

Errors

StatusWhenmessage
400templateId missing or not an ObjectIdtemplateId must be a mongodb id
400status missingstatus must be a string
400A participant account_id is not an ObjectIdparticipants.1.account_id must be a mongodb id
400participants missing or emptyAt least one participant is required to create a share
400No participant has the organiser roleOrganiser not found
400Body is not valid JSONJSON parser error text (this response has no requestId)
401Authorization or tokenId header missingError: Token Missing
401tokenId not recognisedHttpException: No record found with the provided Token ID
500status is not open or completed (for example closed)Internal server error

Field validation errors include errorCode and error. When several fields fail, their messages are joined with , :

{
  "statusCode": 400,
  "errorCode": "Bad Request",
  "error": "Bad Request",
  "message": "templateId must be a mongodb id, status must be a string",
  "timestamp": "2026-03-09T09:39:44.886Z",
  "path": "/di/share",
  "requestId": "3f2b8c1e-7d4a-4e9b-a1c6-5d8e2f0b9a71"
}

Other errors leave out errorCode and error:

{
  "statusCode": 400,
  "message": "At least one participant is required to create a share",
  "timestamp": "2026-03-09T09:39:44.886Z",
  "path": "/di/share",
  "requestId": "3f2b8c1e-7d4a-4e9b-a1c6-5d8e2f0b9a71"
}

Note: The API does not check that templateId belongs to an existing template or that accountType is user or organisation. A share created with an unknown template ID returns "template": null from Read Share.


Did this page help you?