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

# Update Defendant

> Updates a defendant. Only provided fields are updated.
Send `null` for a field to clear its value. Omit a field to preserve its existing value.

**Required permission:** `company.event:export`




## OpenAPI

````yaml /openapi/generated-external-api.yaml patch /api/external/companies/{companyId}/events/{eventId}/lawsuit/defendants/{defendantId}
openapi: 3.0.3
info:
  title: AI Insurance External API
  description: External API for AI Insurance platform
  version: 1.0.0
  contact:
    email: support@aiinsurance.io
servers:
  - url: https://app.aiinsurance.io
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /api/external/companies/{companyId}/events/{eventId}/lawsuit/defendants/{defendantId}:
    patch:
      tags:
        - Defendants
      summary: Update Defendant
      description: >
        Updates a defendant. Only provided fields are updated.

        Send `null` for a field to clear its value. Omit a field to preserve its
        existing value.


        **Required permission:** `company.event:export`
      operationId: updateDefendant
      parameters:
        - $ref: '#/components/parameters/companyId'
        - $ref: '#/components/parameters/eventId'
        - $ref: '#/components/parameters/defendantId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateDefendantRequest'
            examples:
              updateContact:
                summary: Update contact information
                value:
                  email: newemail@example.com
                  phoneNumber: +1-555-999-8888
              assignAttorney:
                summary: Assign a defense attorney
                value:
                  attorneyId: 880e8400-e29b-41d4-a716-446655440000
              clearFields:
                summary: Clear nullable fields
                value:
                  email: null
                  phoneNumber: null
                  attorneyId: null
      responses:
        '200':
          description: Updated defendant details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Defendant'
              examples:
                success:
                  summary: Defendant updated
                  value:
                    id: 550e8400-e29b-41d4-a716-446655440001
                    companyId: 660e8400-e29b-41d4-a716-446655440000
                    lawsuitId: 770e8400-e29b-41d4-a716-446655440000
                    insuredId: null
                    nonInsuredName: John Doe
                    phoneNumber: +1-555-999-8888
                    email: newemail@example.com
                    attorneyId: 880e8400-e29b-41d4-a716-446655440000
                    lawFirmId: null
                    createdAt: '2026-02-15T10:30:00.000Z'
                    updatedAt: '2026-02-19T14:20:00.000Z'
        '400':
          description: Bad Request - Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalidAttorneyId:
                  summary: Invalid attorney reference
                  value:
                    error:
                      code: VALIDATION_ERROR
                      message: Attorney not found in this company
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: Defendant not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                defendantNotFound:
                  summary: Defendant not found
                  value:
                    error:
                      code: NOT_FOUND
                      message: Defendant not found
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    companyId:
      name: companyId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Company identifier
    eventId:
      name: eventId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Event identifier
    defendantId:
      name: defendantId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Defendant identifier
  schemas:
    UpdateDefendantRequest:
      type: object
      properties:
        insuredId:
          type: string
          format: uuid
          nullable: true
          description: >-
            Update associated insured (send null to clear; mutually exclusive
            with nonInsuredName)
        nonInsuredName:
          type: string
          nullable: true
          description: >-
            Update non-insured defendant name (send null to clear; mutually
            exclusive with insuredId)
        phoneNumber:
          type: string
          nullable: true
          description: Update phone number (send null to clear)
        email:
          type: string
          nullable: true
          description: Update email address (send null to clear)
        attorneyId:
          type: string
          format: uuid
          nullable: true
          description: >-
            Update associated attorney (send null to clear; must reference an
            existing attorney)
        lawFirmId:
          type: string
          format: uuid
          nullable: true
          description: >-
            Update associated law firm (send null to clear; must reference an
            existing payee)
    Defendant:
      type: object
      description: A defendant associated with a lawsuit
      properties:
        id:
          type: string
          format: uuid
          description: Defendant identifier
        companyId:
          type: string
          format: uuid
          description: Company identifier
        lawsuitId:
          type: string
          format: uuid
          description: Associated lawsuit identifier
        insuredId:
          type: string
          format: uuid
          nullable: true
          description: >-
            Associated insured identifier (mutually exclusive with
            nonInsuredName)
        nonInsuredName:
          type: string
          nullable: true
          description: Name of non-insured defendant (mutually exclusive with insuredId)
        phoneNumber:
          type: string
          nullable: true
          description: Defendant phone number
        email:
          type: string
          format: email
          nullable: true
          description: Defendant email address
        attorneyId:
          type: string
          format: uuid
          nullable: true
          description: Associated attorney identifier
        lawFirmId:
          type: string
          format: uuid
          nullable: true
          description: Associated law firm payee identifier
        createdAt:
          type: string
          format: date-time
          nullable: true
          description: When the defendant was created (ISO 8601)
        updatedAt:
          type: string
          format: date-time
          nullable: true
          description: When the defendant was last updated (ISO 8601)
    ErrorResponse:
      type: object
      description: Standard error response for all external API endpoints
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Machine-readable error code
              example: VALIDATION_ERROR
            message:
              type: string
              description: Human-readable error message
              example: 'submissionId: Required field is missing'
            details:
              type: array
              description: Additional details for validation errors (field-level errors)
              items:
                type: object
                properties:
                  field:
                    type: string
                    description: The field that caused the error
                    example: submissionId
                  message:
                    type: string
                    description: Description of the field error
                    example: Required field is missing
  responses:
    Unauthorized:
      description: Unauthorized - Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingApiKey:
              summary: Missing API key
              value:
                error:
                  code: UNAUTHORIZED
                  message: Authorization header is required
            bearerTokenNotAllowed:
              summary: Bearer token used instead of API key
              value:
                error:
                  code: UNAUTHORIZED
                  message: External API endpoints require API key authentication
    Forbidden:
      description: Forbidden - Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            insufficientPermissions:
              summary: Insufficient permissions
              value:
                error:
                  code: FORBIDDEN
                  message: Insufficient permissions to perform this action
    InternalServerError:
      description: Internal Server Error - Unexpected error occurred
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            internalError:
              summary: Unexpected server error
              value:
                error:
                  code: INTERNAL_ERROR
                  message: An unexpected error occurred. Please try again later.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        API key authentication. Include your API key in the Authorization
        header.

````