> ## 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 CrmOpportunity

> Create a new CrmOpportunity record.

A **CrmOpportunity** represents a potential or existing deal linked to a customer record that moves through stages on a CRM board.

Opportunities track the lifecycle of a customer interaction — from initial enquiry or tour request through to a won or lost outcome. Each opportunity sits in a single CRM stage (`CrmBoardColumn`) and can be moved between stages manually or automatically via stage auto-assignment rules.

Key fields:

* **Status** — `InProgress`, `Won`, or `Lost`. Stages with `WinOpportunity` or `LoseOpportunity` update this automatically.
* **LeadSource** — how the opportunity was acquired (e.g. Web, Phone, Referral, Broker, GoogleSearch).
* **LossReason** — why the opportunity was lost (e.g. Price, Competition, Location). Only meaningful when Status is `Lost`.
* **Value** — expected revenue if the opportunity is won.
* **DueDate** — follow-up date for the opportunity.
* **UTM fields** — automatically populated from the URL the opportunity used to reach the sign-up or contact form.

There is a limit of 5,000 opportunities per location.

## 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 **`CrmOpportunity-Create`** role.
</Note>

## Enums

<Accordion title="eCrmOpportunitySource">
  | Value | Name               |
  | ----- | ------------------ |
  | 1     | Web                |
  | 2     | Phone              |
  | 4     | Webinar            |
  | 5     | Referral           |
  | 6     | PrintAdvert        |
  | 7     | PurchasedList      |
  | 8     | WordOfMouth        |
  | 9     | DirectEmail        |
  | 10    | EmailMarketing     |
  | 11    | Broker             |
  | 12    | PropertyAgent      |
  | 13    | Facebook           |
  | 14    | Linkedin           |
  | 15    | Instagram          |
  | 16    | Twitter            |
  | 17    | HubbleHq           |
  | 18    | LiquidSpace        |
  | 19    | GoogleSearch       |
  | 20    | SpacePool          |
  | 21    | InstantOffices     |
  | 22    | OfficeFreedom      |
  | 23    | FlexiOffices       |
  | 24    | Workthere          |
  | 25    | Kontor             |
  | 26    | Valve              |
  | 98    | OtherSocialNetwork |
  | 99    | Other              |
</Accordion>

<Accordion title="eCrmOpportunityLossReason">
  | Value | Name              |
  | ----- | ----------------- |
  | 1     | Timing            |
  | 2     | Need              |
  | 3     | PoorQualification |
  | 4     | Price             |
  | 5     | Feature           |
  | 6     | LostMomentum      |
  | 7     | Competition       |
  | 8     | ContractTerm      |
  | 9     | Duplicate         |
  | 10    | Waitlist          |
  | 11    | NotReturningCalls |
  | 12    | LackOfFacilities  |
  | 13    | NoPetPolicy       |
  | 14    | NoRightFit        |
  | 15    | Location          |
  | 16    | Entrance          |
  | 17    | Errors            |
  | 18    | Archived          |
  | 19    | SearchOnHold      |
  | 20    | RelocationOnHold  |
  | 99    | Other             |
</Accordion>

<Accordion title="eCrmOpportunityStatus — Status values">
  | Value | Name       |
  | ----- | ---------- |
  | 1     | InProgress |
  | 2     | Won        |
  | 3     | Lost       |
</Accordion>

## Request Body

### Required Fields

<ParamField body="CrmBoardColumnId" type="integer" required>
  Crm Board Column Id.
</ParamField>

<ParamField body="CoworkerId" type="integer" required>
  Coworker Id.
</ParamField>

<ParamField body="Status" type="integer" required>
  Opportunity status: InProgress (still active), Won (led to a sale), or Lost (did not lead to a sale). Defaults to `InProgress`.
</ParamField>

<ParamField body="Position" type="integer" required>
  Display order of the opportunity within its current stage.
</ParamField>

### Optional Fields

<ParamField body="Name" type="string">
  Optional tag to identify this opportunity, useful when the same customer appears in multiple boards.
</ParamField>

<ParamField body="TeamId" type="integer">
  Team Id.
</ParamField>

<ParamField body="OpportunityTypeId" type="integer">
  Opportunity type used to categorise and auto-populate general notes from a template.
</ParamField>

<ParamField body="ResponsibleId" type="integer">
  Admin user responsible for managing this opportunity.
</ParamField>

<ParamField body="ReferrerId" type="integer">
  Customer who referred this opportunity.
</ParamField>

<ParamField body="AgentId" type="integer">
  External agent or broker who brought this opportunity.
</ParamField>

<ParamField body="Notes" type="string">
  General notes visible to admins when viewing the opportunity. Auto-populated from the opportunity type template if a type is assigned.
</ParamField>

<ParamField body="Completed" type="boolean">
  Whether the opportunity has been completed (won or lost).
</ParamField>

<ParamField body="DueDate" type="string">
  Follow-up date for the opportunity.
</ParamField>

<ParamField body="Value" type="number">
  Expected revenue if the opportunity is won.
</ParamField>

<ParamField body="Reminded" type="boolean">
  Whether a follow-up reminder has been sent for this opportunity.
</ParamField>

<ParamField body="LeadSource" type="integer">
  How the opportunity was acquired (e.g. Web, Phone, Referral, Broker, GoogleSearch). See `eCrmOpportunitySource?` enum above.
</ParamField>

<ParamField body="LossReason" type="integer">
  Why the opportunity was lost (e.g. Price, Competition, Location). Only relevant when Status is Lost. See `eCrmOpportunityLossReason?` enum above.
</ParamField>

<ParamField body="WonOn" type="string">
  Date when the opportunity was marked as won.
</ParamField>

<ParamField body="LostOn" type="string">
  Date when the opportunity was marked as lost.
</ParamField>

<ParamField body="UtmSource" type="string">
  UTM source parameter captured from the URL the opportunity used.
</ParamField>

<ParamField body="UtmMedium" type="string">
  UTM medium parameter captured from the URL the opportunity used.
</ParamField>

<ParamField body="UtmCampaign" type="string">
  UTM campaign parameter captured from the URL the opportunity used.
</ParamField>

<ParamField body="UtmContent" type="string">
  UTM content parameter captured from the URL the opportunity used.
</ParamField>

<ParamField body="UtmTerm" type="string">
  UTM term parameter captured from the URL the opportunity used.
</ParamField>

## Code Examples

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

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

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

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

  response = requests.post(
      'https://spaces.nexudus.com/api/crm/crmopportunities',
      headers={
          'Authorization': 'Bearer YOUR_TOKEN',
          'Content-Type': 'application/json'
      },
      json={
          'CrmBoardColumnId': 0,
          'CoworkerId': None,
          'Status': 0,
          'Position': 0
      }
  )

  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 crmopportunity was created successfully.
</ResponseField>

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

```json Example Response theme={null}
{
  "Status": 200,
  "Message": "CrmOpportunity 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": "Status: is a required field",
  "Value": null,
  "Errors": [
    {
      "AttemptedValue": null,
      "Message": "is a required field",
      "PropertyName": "Status"
    }
  ],
  "WasSuccessful": false
}
```
