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

# Create Patient Plan

### How to get the payor\_entity\_id

Use the [Get Payors API](/api-reference/v1payorsresource/get-payors).

### Handling Conflicts

Using the `conflict_behavior` field allows you to configure how existing plans are handled when a patient plan already
exists at the specified `plan_order_number`.

* The default is `RAISE_ERROR` and will return a Conflict Error (http status of 409)
* `BUMP_ONE` will move the existing plan at the specified order to the next order number. For example, if you create
  a new primary plan (order 1) and a primary plan already exists, the existing plan will be moved to secondary (order 2).
  Note that this will fail with a Conflict Error (409) if the next order number is also occupied.

### Create Patient Plan With Insurance Card

If you want to create a patient plan with an insurance card, you will need to do the following steps:

1. Upload the front of the insurance card to the [File Upload API](/api-reference/v1fileresource/upload-file) and get the `file_id` from the response.
2. Upload the back of the insurance card to the [File Upload API](/api-reference/v1fileresource/upload-file) and get the `file_id` from the response.
3. Make a post request to this api with the `file_ids` returned from 1 and 2 as the `insurance_card_file_id` and `insurance_card_back_file_id`, respectively.


## OpenAPI

````yaml post /public/v1/patient-plans/
openapi: 3.0.2
info:
  title: Silna Public API
  version: '1.0'
servers:
  - url: https://app.silnahealth.com/api
security:
  - bearerAuth: []
paths:
  /public/v1/patient-plans/:
    post:
      tags:
        - V1PatientPlanResource
      summary: Create Patient Plan
      operationId: V1PatientPlanResource.post
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/V1PatientPlanCreate'
        description: |2-

              Request schema for creating a patient plan
              
      responses:
        '201':
          description: |2-

                Response schema for creating a patient plan
                
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V1PatientPlanCreateResponse'
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
                description: The maximum number of requests allowed in the time window
            X-RateLimit-Remaining:
              schema:
                type: integer
                description: The number of requests remaining in the current time window
            X-RateLimit-Reset:
              schema:
                type: integer
                description: The time when the rate limit will reset, in Unix timestamp
            Retry-After:
              schema:
                type: number
                description: The number of seconds to wait before making another request
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
                description: The maximum number of requests allowed in the time window
            X-RateLimit-Remaining:
              schema:
                type: integer
                description: The number of requests remaining in the current time window
            X-RateLimit-Reset:
              schema:
                type: integer
                description: The time when the rate limit will reset, in Unix timestamp
            Retry-After:
              schema:
                type: number
                description: The number of seconds to wait before making another request
        '401':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthenticationError'
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
                description: The maximum number of requests allowed in the time window
            X-RateLimit-Remaining:
              schema:
                type: integer
                description: The number of requests remaining in the current time window
            X-RateLimit-Reset:
              schema:
                type: integer
                description: The time when the rate limit will reset, in Unix timestamp
            Retry-After:
              schema:
                type: number
                description: The number of seconds to wait before making another request
        '404':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ObjectNotFoundError'
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
                description: The maximum number of requests allowed in the time window
            X-RateLimit-Remaining:
              schema:
                type: integer
                description: The number of requests remaining in the current time window
            X-RateLimit-Reset:
              schema:
                type: integer
                description: The time when the rate limit will reset, in Unix timestamp
            Retry-After:
              schema:
                type: number
                description: The number of seconds to wait before making another request
        '409':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConflictError'
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
                description: The maximum number of requests allowed in the time window
            X-RateLimit-Remaining:
              schema:
                type: integer
                description: The number of requests remaining in the current time window
            X-RateLimit-Reset:
              schema:
                type: integer
                description: The time when the rate limit will reset, in Unix timestamp
            Retry-After:
              schema:
                type: number
                description: The number of seconds to wait before making another request
        '429':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TooManyRequestsError'
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
                description: The maximum number of requests allowed in the time window
            X-RateLimit-Remaining:
              schema:
                type: integer
                description: The number of requests remaining in the current time window
            X-RateLimit-Reset:
              schema:
                type: integer
                description: The time when the rate limit will reset, in Unix timestamp
            Retry-After:
              schema:
                type: number
                description: The number of seconds to wait before making another request
components:
  schemas:
    V1PatientPlanCreate:
      description: Request schema for creating a patient plan
      properties:
        member_number:
          maxLength: 80
          minLength: 2
          title: Member Number
          type: string
        group_number:
          default: null
          title: Group Number
          nullable: true
          maxLength: 80
          minLength: 2
          type: string
        start_date:
          default: null
          title: Start Date
          nullable: true
          format: date-time
          type: string
        end_date:
          default: null
          title: End Date
          nullable: true
          format: date-time
          type: string
        payor_entity_id:
          format: uuid
          title: Payor Entity Id
          type: string
        insurance_type:
          $ref: '#/components/schemas/InsuranceType'
          default: null
          description: The type of insurance
          nullable: true
        source_id:
          default: null
          description: >-
            Unique identifier for the patient plan. This is (optionally)
            generated and supplied by API clients
          title: Source Id
          nullable: true
          type: string
        patient_id:
          format: uuid
          title: Patient Id
          type: string
        plan_order_number:
          description: The order number of the plan (1 for primary, 2 for secondary, etc)
          title: Plan Order Number
          type: integer
        insurance_card_file_id:
          default: null
          description: The file ID corresponding to the front of the insurance card
          title: Insurance Card File Id
          nullable: true
          format: uuid
          type: string
        insurance_card_back_file_id:
          default: null
          description: The file ID corresponding to the back of the insurance card
          title: Insurance Card Back File Id
          nullable: true
          format: uuid
          type: string
        conflict_behavior:
          $ref: '#/components/schemas/APIPatientPlanCreateConflictBehavior'
          default: RAISE_ERROR
          description: >-
            How to handle a conflict when a patient plan already exists at the
            specified plan_order_number. RAISE_ERROR (default) will return a 409
            Conflict error. BUMP_ONE will move the existing plan at the
            specified order to the next order number (e.g., primary becomes
            secondary).
          nullable: true
      required:
        - member_number
        - payor_entity_id
        - patient_id
        - plan_order_number
      title: V1PatientPlanCreate
      type: object
      x-folder: public_api
    V1PatientPlanCreateResponse:
      description: Response schema for creating a patient plan
      properties:
        patient_plan_id:
          format: uuid
          title: Patient Plan Id
          type: string
      required:
        - patient_plan_id
      title: V1PatientPlanCreateResponse
      type: object
      x-folder: public_api
    ValidationError:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          description: Human readable error message
      x-folder: null
    AuthenticationError:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          description: Human readable error message
        type:
          $ref: '#/components/schemas/PublicApiErrorType'
      x-folder: null
    ObjectNotFoundError:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          description: Human readable error message
      x-folder: null
    ConflictError:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          description: Human readable error message
      x-folder: null
    TooManyRequestsError:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          description: Human readable error message
      x-folder: null
    InsuranceType:
      type: string
      enum:
        - COMMERCIAL
        - MEDICARE
        - MEDICAID
        - REGIONAL_CENTER
        - WORKERS_COMPENSATION
        - AUTO_INSURANCE
      x-folder: patient
    APIPatientPlanCreateConflictBehavior:
      type: string
      enum:
        - RAISE_ERROR
        - BUMP_ONE
      x-folder: patient
    PublicApiErrorType:
      type: string
      enum:
        - AUTH_INVALID_REQUEST_HEADER
        - AUTH_INVALID_CREDENTIALS
      x-folder: null
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````