# Create an opportunity

POST https://api.close.com/api/v1/opportunity/
Content-Type: application/json

**status_id** (optional): Post a `status_id` to create an opportunity with a specific status. If omitted, the organization's default (first) status will be used. See the [Opportunity Status API](/resources/opportunity-statuses/).

**lead_id** (optional): Opportunities belong to exactly one Lead. If you do not provide a `lead_id` then a new lead will be created (appearing as "Untitled" in the UI).

**custom.FIELD_ID** (optional): Set custom fields by setting `custom.FIELD_ID` to the field value, where FIELD_ID is the ID of the custom field, e.g.:

```json
{ "custom.cf_v6S011I6MqcbVvB2FA5Nk8dr5MkL8sWuCiG8cUleO9c": "value", "custom.cf_8wtBWsdRU2Fur7GDnEeXQ7ra2Vu7R4hG1SNYdiEhh0F": "other value" }
```

If a custom field has `accepts_multiple_values: true`, the entire value will be replaced. For example, given an Opportunity has a Custom Choice Field with value `["A", "B"]`, adding choice `"C"` would mean setting the value to `["A", "B", "C"]`.

Note that using the `custom` field dict or the `custom.FIELD_NAME` syntax (instead of custom field IDs) is deprecated and will be removed from the API. See [Custom Fields](/resources/custom-fields/) for more details.

Reference: https://developer.close.com/api/resources/opportunities/create

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Close API
  version: 1.0.0
paths:
  /opportunity/:
    post:
      operationId: create
      summary: Create an opportunity
      description: >-
        **status_id** (optional): Post a `status_id` to create an opportunity
        with a specific status. If omitted, the organization's default (first)
        status will be used. See the [Opportunity Status
        API](/resources/opportunity-statuses/).


        **lead_id** (optional): Opportunities belong to exactly one Lead. If you
        do not provide a `lead_id` then a new lead will be created (appearing as
        "Untitled" in the UI).


        **custom.FIELD_ID** (optional): Set custom fields by setting
        `custom.FIELD_ID` to the field value, where FIELD_ID is the ID of the
        custom field, e.g.:


        ```json

        { "custom.cf_v6S011I6MqcbVvB2FA5Nk8dr5MkL8sWuCiG8cUleO9c": "value",
        "custom.cf_8wtBWsdRU2Fur7GDnEeXQ7ra2Vu7R4hG1SNYdiEhh0F": "other value" }

        ```


        If a custom field has `accepts_multiple_values: true`, the entire value
        will be replaced. For example, given an Opportunity has a Custom Choice
        Field with value `["A", "B"]`, adding choice `"C"` would mean setting
        the value to `["A", "B", "C"]`.


        Note that using the `custom` field dict or the `custom.FIELD_NAME`
        syntax (instead of custom field IDs) is deprecated and will be removed
        from the API. See [Custom Fields](/resources/custom-fields/) for more
        details.
      tags:
        - subpackage_opportunities
      parameters:
        - name: Authorization
          in: header
          description: Basic authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Opportunity'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                description: Any type
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                description: Any type
        '404':
          description: Not found
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOpportunity'
servers:
  - url: https://api.close.com/api/v1
components:
  schemas:
    AttachmentIn:
      type: object
      properties:
        content_type:
          type: string
          default: ''
        filename:
          type: string
        url:
          type: string
      required:
        - filename
        - url
      title: AttachmentIn
    OpportunityValuePeriod:
      type: string
      enum:
        - one_time
        - monthly
        - annual
      title: OpportunityValuePeriod
    CreateOpportunity:
      type: object
      properties:
        attachments:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/AttachmentIn'
        confidence:
          type:
            - integer
            - 'null'
        contact_id:
          type:
            - string
            - 'null'
        created_by:
          type:
            - string
            - 'null'
        custom_fields:
          type:
            - object
            - 'null'
          additionalProperties:
            description: Any type
        date_created:
          type:
            - string
            - 'null'
          format: date-time
        date_won:
          type:
            - string
            - 'null'
          format: date-time
        lead_id:
          type:
            - string
            - 'null'
        note:
          type:
            - string
            - 'null'
        status_id:
          type:
            - string
            - 'null'
        user_id:
          type:
            - string
            - 'null'
        value:
          type:
            - integer
            - 'null'
        value_period:
          oneOf:
            - $ref: '#/components/schemas/OpportunityValuePeriod'
            - type: 'null'
      title: CreateOpportunity
    Attachment:
      type: object
      properties:
        content_type:
          type:
            - string
            - 'null'
        filename:
          type:
            - string
            - 'null'
        size:
          type:
            - integer
            - 'null'
        thumbnail_url:
          type:
            - string
            - 'null'
        url:
          type: string
      required:
        - content_type
        - filename
        - size
        - url
      title: Attachment
    CommentSummary:
      type: object
      properties:
        comment_count:
          type: integer
        thread_id:
          type: string
      required:
        - comment_count
        - thread_id
      title: CommentSummary
    RenderedIntegrationLink:
      type: object
      properties:
        name:
          type: string
        url:
          type: string
      required:
        - name
        - url
      title: RenderedIntegrationLink
    ContactEmail:
      type: object
      properties:
        email:
          type: string
        is_unsubscribed:
          type: boolean
        type:
          type: string
      required:
        - email
        - is_unsubscribed
        - type
      title: ContactEmail
    ContactPhone:
      type: object
      properties:
        country:
          type:
            - string
            - 'null'
        outbound_sms_blocked:
          type: boolean
        phone:
          type: string
        phone_formatted:
          type: string
        type:
          type: string
        tz_ids:
          type: array
          items:
            type: string
      required:
        - phone
        - type
      title: ContactPhone
    StalledOpportunityCommunicationIssue:
      type: string
      enum:
        - no_issue
        - cant_get_in_touch
        - no_communication_attempts
      title: StalledOpportunityCommunicationIssue
    StalledOpportunityActionTypeV1:
      type: string
      enum:
        - mark_as_lost
        - change_status
        - follow_up
        - adjust_close_date
        - ask_someone_else_to_reach_out
        - change_communication_method
      title: StalledOpportunityActionTypeV1
    ActionItem:
      type: object
      properties:
        action:
          $ref: '#/components/schemas/StalledOpportunityActionTypeV1'
          description: >-
            The recommended next step to progress or resolve the stalled
            opportunity
        justification:
          type: string
          description: >-
            A short justification for the recommended action in the sales
            pipeline. Maximum 2 sentences.
      required:
        - action
        - justification
      title: ActionItem
    StalledOpportunityActionItems:
      type: object
      properties:
        communication_issue:
          $ref: '#/components/schemas/StalledOpportunityCommunicationIssue'
          description: >-
            The communication issue that is causing the stalled opportunity. If
            there is no issue, set to NoIssue.
        next_action:
          $ref: '#/components/schemas/ActionItem'
          description: >-
            An action item recommended to progress or resolve the stalled
            opportunity.
      required:
        - communication_issue
        - next_action
      title: StalledOpportunityActionItems
    OpportunityStatusType:
      type: string
      enum:
        - won
        - lost
        - active
      title: OpportunityStatusType
    StalledOpportunityActionTypeV2:
      type: string
      enum:
        - change_status
        - adjust_close_date
        - follow_up_email
        - follow_up_call
        - follow_up_sms
      title: StalledOpportunityActionTypeV2
    OpportunityChangeStatusActionDetails:
      type: object
      properties:
        status_id:
          type: string
      required:
        - status_id
      title: OpportunityChangeStatusActionDetails
    OpportunityFollowUpEmailActionDetails:
      type: object
      properties:
        contact_id:
          type: string
        message_draft:
          type: string
        subject_draft:
          type: string
      required:
        - contact_id
        - message_draft
        - subject_draft
      title: OpportunityFollowUpEmailActionDetails
    OpportunityFollowUpSMSActionDetails:
      type: object
      properties:
        contact_id:
          type: string
        message_draft:
          type: string
      required:
        - contact_id
        - message_draft
      title: OpportunityFollowUpSMSActionDetails
    OpportunityFollowUpCallActionDetails:
      type: object
      properties:
        call_plan:
          type: string
        contact_id:
          type: string
      required:
        - call_plan
        - contact_id
      title: OpportunityFollowUpCallActionDetails
    OpportunityAdjustCloseDateActionDetails:
      type: object
      properties:
        close_date:
          type: string
          format: date
      required:
        - close_date
      title: OpportunityAdjustCloseDateActionDetails
    OpportunitySuggestedActionDetails:
      oneOf:
        - $ref: '#/components/schemas/OpportunityChangeStatusActionDetails'
        - $ref: '#/components/schemas/OpportunityFollowUpEmailActionDetails'
        - $ref: '#/components/schemas/OpportunityFollowUpSMSActionDetails'
        - $ref: '#/components/schemas/OpportunityFollowUpCallActionDetails'
        - $ref: '#/components/schemas/OpportunityAdjustCloseDateActionDetails'
      title: OpportunitySuggestedActionDetails
    OpportunitySuggestedAction:
      type: object
      properties:
        action:
          $ref: '#/components/schemas/StalledOpportunityActionTypeV2'
        details:
          oneOf:
            - $ref: '#/components/schemas/OpportunitySuggestedActionDetails'
            - type: 'null'
        justification:
          type: string
      required:
        - action
        - details
        - justification
      title: OpportunitySuggestedAction
    Opportunity:
      type: object
      properties:
        annualized_expected_value:
          type:
            - integer
            - 'null'
        annualized_value:
          type:
            - integer
            - 'null'
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/Attachment'
        comment_summary:
          oneOf:
            - $ref: '#/components/schemas/CommentSummary'
            - type: 'null'
        confidence:
          type: integer
        contact_id:
          type:
            - string
            - 'null'
        contact_name:
          type:
            - string
            - 'null'
        created_by:
          type:
            - string
            - 'null'
        created_by_name:
          type:
            - string
            - 'null'
        date_created:
          type: string
          format: date-time
        date_lost:
          type:
            - string
            - 'null'
          format: date-time
        date_updated:
          type: string
          format: date-time
        date_won:
          type:
            - string
            - 'null'
          format: date
        expected_value:
          type:
            - integer
            - 'null'
        id:
          type: string
        integration_links:
          type: array
          items:
            $ref: '#/components/schemas/RenderedIntegrationLink'
        is_stalled:
          type: boolean
        lead_id:
          type: string
        lead_name:
          type:
            - string
            - 'null'
        lead_primary_email:
          oneOf:
            - $ref: '#/components/schemas/ContactEmail'
            - type: 'null'
        lead_primary_phone:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/ContactPhone'
        note:
          type:
            - string
            - 'null'
        organization_id:
          type: string
        pipeline_id:
          type:
            - string
            - 'null'
        pipeline_name:
          type:
            - string
            - 'null'
        stall_status:
          oneOf:
            - $ref: '#/components/schemas/StalledOpportunityActionItems'
            - type: 'null'
        status_display_name:
          type: string
        status_id:
          type: string
        status_label:
          type: string
        status_type:
          $ref: '#/components/schemas/OpportunityStatusType'
        suggested_action:
          oneOf:
            - $ref: '#/components/schemas/OpportunitySuggestedAction'
            - type: 'null'
        updated_by:
          type:
            - string
            - 'null'
        updated_by_name:
          type:
            - string
            - 'null'
        user_id:
          type: string
        user_name:
          type:
            - string
            - 'null'
        value:
          type:
            - integer
            - 'null'
        value_currency:
          type:
            - string
            - 'null'
        value_formatted:
          type:
            - string
            - 'null'
        value_period:
          $ref: '#/components/schemas/OpportunityValuePeriod'
      required:
        - annualized_expected_value
        - annualized_value
        - confidence
        - contact_id
        - created_by
        - date_created
        - date_lost
        - date_updated
        - date_won
        - expected_value
        - id
        - lead_id
        - note
        - organization_id
        - status_id
        - updated_by
        - user_id
        - value
        - value_period
      title: Opportunity
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: basic
    OAuth2:
      type: http
      scheme: bearer

```