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

# Cancel a Payin

This endpoint allows you to cancel a Payin transaction that is in an authorized state. The transaction will be marked as cancelled and any pending funds will be released.


## OpenAPI

````yaml openapi/localpayment.json PATCH /api/transactions/{externalId}/status
openapi: 3.1.0
info:
  version: '1.0'
  title: Localpayment
  contact:
    name: Support
    url: mailto:support@localpayment.com
servers:
  - url: https://api.stage.localpayment.com
    description: Stage
security:
  - token: []
paths:
  /api/transactions/{externalId}/status:
    patch:
      summary: Cancel a Payin
      operationId: cancel-payin
      parameters:
        - name: Authorization
          in: header
          description: >-
            Bearer access token for authentication. This token is obtained from
            the [Get Access Token](/reference/get-token) or [Refresh Access
            Token](/reference/refresh-token) endpoints.
          required: true
          schema:
            type: string
        - name: externalId
          in: path
          description: >-
            ID generated on your side for transaction traceability. It must be
            unique and only accepts alphanumeric characters and hyphens (UUID4
            for example). You can also retrieve a transaction's status using its
            internal Id.
          required: true
          schema:
            type: string
            pattern: '[a-zA-Z0-9\- ]+'
            examples:
              - 53025bf4-4c87-4b4f-8fea-b47004440f37
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  const: CANCELLED
                  description: Change the status to `CANCELLED`.
              required:
                - status
              x-examples:
                Example 1:
                  status: CANCELLED
            examples:
              CANCELLED:
                value:
                  status: CANCELLED
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  externalId:
                    type: string
                    description: >-
                      A unique identifier generated by your system to track the
                      transaction (alphanumeric and hyphens). We recommend using
                      UUID4 to ensure uniqueness.
                  internalId:
                    type: string
                    description: Localpayment transaction identifier.
                  status:
                    $ref: '#/components/schemas/status'
                x-examples:
                  Example 1:
                    externalId: '1623539480'
                    internalId: 764355d7-9935-4716-8e26-0f507ba2e6f8
                    status:
                      code: '900'
                      description: CANCELLED
                      detail: The payin was cancelled
              examples:
                900 - The payin was cancelled.:
                  value:
                    externalId: e36ef929-c2d4-fcf0-b30c-99dc51798f4b
                    internalId: c09095fb-6a0e-47af-9f43-3d9452b0f290
                    status:
                      code: '900'
                      description: CANCELLED
                      detail: The payin was cancelled
        '400':
          description: Bad Request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: object
                    title: status
                    description: Operation status.
                    properties:
                      code:
                        type: string
                        description: >-
                          [Status
                          code](/reference/transaction-status-error-codes).
                      description:
                        type: string
                        description: >-
                          [Status
                          description](/reference/transaction-status-error-codes).
                      detail:
                        type: string
                        description: Additional status information.
                  errors:
                    type: array
                    description: List of errors that occurred during the transaction.
                    items:
                      type: object
                      properties:
                        code:
                          type: string
                          description: Error code.
                        description:
                          type: string
                          description: Error description.
                        detail:
                          type: string
                          description: Additional details.
                x-examples:
                  Example 1:
                    status:
                      code: '300'
                      description: REJECTED
                      detail: Invalid param + [status] + [Is mandatory]
                    errors:
                      - code: '300'
                        description: REJECTED
                        detail: Invalid param + [status] + [Is mandatory]
              examples:
                300 - Invalid param.:
                  value:
                    status:
                      code: '300'
                      description: REJECTED
                      detail: Invalid param + [status] + [Is mandatory]
                    errors:
                      - code: '300'
                        description: REJECTED
                        detail: Invalid param + [status] + [Is mandatory]
                400 - Invalid operation.:
                  value:
                    status:
                      code: '400'
                      description: ERROR
                      detail: Invalid operation
        '401':
          description: Unauthorized.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    description: Additional information of the response.
                  code:
                    type: string
                    description: Status code.
                  messages:
                    type: array
                    description: Message list.
                    items:
                      type: object
                      properties:
                        token_class:
                          type: string
                          description: Token class.
                        token_type:
                          type: string
                          description: Token type.
                        message:
                          type: string
                          description: Message with additional information.
                x-examples:
                  Example 1:
                    detail: Given token not valid for any token type
                    code: token_not_valid
                    messages:
                      - token_class: AccessToken
                        token_type: access
                        message: Token is invalid or expired
              examples:
                401 - Token is invalid or expired:
                  value:
                    detail: Given token not valid for any token type
                    code: token_not_valid
                    messages:
                      - token_class: AccessToken
                        token_type: access
                        message: Token is invalid or expired
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: object
                    properties:
                      code:
                        type: string
                        description: >-
                          [Status
                          code](/reference/transaction-status-error-codes).
                      description:
                        type: string
                        description: Status description.
                      detail:
                        type: string
                        description: Additional status information.
                x-examples:
                  Example 1:
                    status:
                      code: '404'
                      description: ERROR
                      detail: Payin not found
              examples:
                404 - Payin not found:
                  value:
                    status:
                      code: '404'
                      description: ERROR
                      detail: Payin not found
      security:
        - token: []
      servers:
        - url: https://api.stage.localpayment.com
          description: Stage
components:
  schemas:
    status:
      type: object
      title: status
      description: Operation status.
      properties:
        code:
          type: string
          description: Status code.
        description:
          type: string
          description: Status description.
        detail:
          type: string
          description: Additional status information.
  securitySchemes:
    token:
      type: http
      scheme: bearer

````

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