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

# Set Post-Call Outcome

> Update custom outcome data for a call.

Updates any supplied custom outcome, numeric value, or metadata for a call belonging to the agent.

Identify the call with either its call ID or a customer phone number. For a phone number, `preference=last` updates the most recent matching call by default; use `preference=first` for the earliest match. Formatting characters are removed before the phone number is validated and matched.

Fields omitted from the request are left unchanged.


## OpenAPI

````yaml PATCH /calls/{agentId}/{callIdOrPhone}
openapi: 3.0.1
info:
  title: Phonely API
  description: API for Phonely services including agent management and call summaries
  version: 1.0.0
servers:
  - url: https://app.phonely.ai/api
security: []
paths:
  /calls/{agentId}/{callIdOrPhone}:
    patch:
      summary: Set post call outcome
      description: >-
        Set post call outcome fields for a call identified by either call ID or
        phone number.
      parameters:
        - name: agentId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the agent
        - name: callIdOrPhone
          in: path
          required: true
          schema:
            type: string
          description: The ID of the call or the E.164 phone number
        - name: preference
          in: query
          required: false
          schema:
            type: string
            enum:
              - first
              - last
            default: last
          description: >-
            first: first time that someone called in, last: latest call from
            someone
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCallOutcomeRequest'
      responses:
        '200':
          description: Call outcome updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateCallOutcomeResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    UpdateCallOutcomeRequest:
      type: object
      additionalProperties: false
      minProperties: 1
      properties:
        custom_call_outcome:
          type: string
          description: The outcome label (e.g., Sold, No Sale)
        custom_call_outcome_value:
          type: number
          description: The monetary value associated with the outcome
        custom_call_metadata:
          type: object
          description: Additional custom metadata for the call
    UpdateCallOutcomeResponse:
      type: object
      required:
        - success
        - call_id
        - agent_id
        - updated_fields
      properties:
        success:
          type: boolean
        call_id:
          type: string
        agent_id:
          type: string
        phone:
          type: string
        preference:
          type: string
        updated_fields:
          type: array
          items:
            type: string
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error code or identifier
        message:
          type: string
          description: Detailed error message
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Authorization

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.