> ## Documentation Index
> Fetch the complete documentation index at: https://learn.nexudus.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create CoworkerDataFile

> Create a new CoworkerDataFile record.

A **CoworkerDataFile** is a file attached to a customer's record. Files can be kept internal or shared with the customer on the Members Portal.

When a file is shared (`AvailableToUser = true`), the customer receives an email notification and can view or download the file from the Files tab under My Activity on the Members Portal.

You can request a digital signature (`RequestDigitalSignature = true`) — once the customer signs the document, a signed copy is automatically stored in `SignedFileDataFileName`. The notes in `Description` are included in the email notification sent to the customer.

Supported formats include .pdf, .docx, .xlsx, .jpg, .png, and other common types (max 10 MB). Files can be linked to a document template, a proposal, or a coworker contract via the respective GUID fields.

## Authentication

<Note>
  This endpoint requires OAuth2 authentication. Include a valid bearer token in the `Authorization` header.
  The authenticated user must be a full unrestricted administrator or have the **`CoworkerDataFile-Create`** role.
</Note>

## Request Body

### Required Fields

<ParamField body="BusinessId" type="integer" required>
  Location ID.
</ParamField>

<ParamField body="CoworkerId" type="integer" required>
  ID of the customer this file belongs to.
</ParamField>

<ParamField body="Name" type="string" required>
  Name of the file or document.
</ParamField>

### Optional Fields

<ParamField body="Description" type="string">
  Notes included in the email notification sent to the customer when the file is shared.
</ParamField>

<ParamField body="AvailableToUser" type="boolean">
  Whether the file is shared with the customer and visible on the Members Portal.
</ParamField>

<ParamField body="RequestDigitalSignature" type="boolean">
  Whether to request a digital signature from the customer.
</ParamField>

<ParamField body="NewFileDataUrl" type="string">
  URL of a new file to upload (replaces the existing file).
</ParamField>

<ParamField body="ClearFileDataFile" type="boolean">
  Set to true to remove the existing uploaded file.
</ParamField>

<ParamField body="NewSignedFileDataUrl" type="string">
  URL of a new signed file to upload (replaces the existing signed copy).
</ParamField>

<ParamField body="ClearSignedFileDataFile" type="boolean">
  Set to true to remove the existing signed copy.
</ParamField>

<ParamField body="Extension" type="string">
  File extension (e.g. pdf, docx, jpg).
</ParamField>

<ParamField body="Billed" type="boolean">
  Whether the customer has been billed for this file.
</ParamField>

<ParamField body="Signed" type="boolean">
  Whether the customer has signed this document.
</ParamField>

<ParamField body="EsignIdentifier" type="string">
  Identifier used by the digital signature provider to track this document.
</ParamField>

<ParamField body="DocumentTemplateGuid" type="string">
  GUID of the document template used to generate this file.
</ParamField>

<ParamField body="NotifyWhenSignedEmail" type="string">
  Email address to notify when the customer signs the document.
</ParamField>

<ParamField body="ProposalGuid" type="string">
  GUID of the proposal linked to this file.
</ParamField>

<ParamField body="CoworkerContractGuid" type="string">
  GUID of the coworker contract linked to this file.
</ParamField>

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST \
    "https://spaces.nexudus.com/api/spaces/coworkerdatafiles" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "BusinessId": 0,
      "CoworkerId": 0,
      "Name": ""
  }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://spaces.nexudus.com/api/spaces/coworkerdatafiles',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        BusinessId: 0,
        CoworkerId: 0,
        Name: ''
      })
    }
  );

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://spaces.nexudus.com/api/spaces/coworkerdatafiles',
      headers={
          'Authorization': 'Bearer YOUR_TOKEN',
          'Content-Type': 'application/json'
      },
      json={
          'BusinessId': 0,
          'CoworkerId': 0,
          'Name': ''
      }
  )

  data = response.json()
  ```
</CodeGroup>

## Response

### 200

<ResponseField name="Status" type="integer">
  HTTP status code. `200` on success.
</ResponseField>

<ResponseField name="Message" type="string">
  A human-readable message confirming the creation.
</ResponseField>

<ResponseField name="Value" type="object">
  Contains the `Id` of the newly created record.
</ResponseField>

<ResponseField name="WasSuccessful" type="boolean">
  `true` if the coworkerdatafile was created successfully.
</ResponseField>

<ResponseField name="Errors" type="array">
  `null` on success.
</ResponseField>

```json Example Response theme={null}
{
  "Status": 200,
  "Message": "CoworkerDataFile was successfully created.",
  "Value": {
    "Id": 87654321
  },
  "OpenInDialog": false,
  "OpenInWindow": false,
  "RedirectURL": null,
  "JavaScript": null,
  "UpdatedOn": "2025-01-15T10:30:00Z",
  "UpdatedBy": "admin@example.com",
  "Errors": null,
  "WasSuccessful": true
}
```

### 400

<ResponseField name="Message" type="string">
  A summary of the validation error(s), in the format `PropertyName: error message`.
</ResponseField>

<ResponseField name="Value" type="any">
  `null` on validation failure.
</ResponseField>

<ResponseField name="Errors" type="object[]">
  Array of validation errors.

  <Expandable>
    <ResponseField name="AttemptedValue" type="any">
      The value that was submitted for the field, or `null` if missing.
    </ResponseField>

    <ResponseField name="Message" type="string">
      The validation error message.
    </ResponseField>

    <ResponseField name="PropertyName" type="string">
      The name of the property that failed validation.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="WasSuccessful" type="boolean">
  `false` when the request fails validation.
</ResponseField>

```json Example Response theme={null}
{
  "Message": "Name: is a required field",
  "Value": null,
  "Errors": [
    {
      "AttemptedValue": null,
      "Message": "is a required field",
      "PropertyName": "Name"
    }
  ],
  "WasSuccessful": false
}
```
