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

# Reassign a Payment Method to Another Customer

> Reassigns an enrolled payment method to a different customer of the same account

Reassign an enrolled payment method to a different customer of the same account. Send the `customer_id` of the target customer in the request body. Only card payment methods can be reassigned. The response returns the payment method in the same shape as the [Enroll Payment Method](/reference/enroll-payment-method-api) response, with the new owner in the `customer_id` field.

<Note>
  To reassign the payment method, you need to provide the `payment_method_id`, which is the `vaulted_token` received when using the [Enroll Payment Method](/reference/enroll-payment-method-api) endpoint.
</Note>

A payment method that is already assigned to a customer that has data cannot be reassigned, and the request is rejected with `409 CONFLICT`.

<Warning>
  After a payment method is reassigned, the merchant is responsible for updating the customer identifier wherever the payment method was already used. This includes any subscription created with it, the merchant's own mapping between a user and the `vaulted_token`, and any stored pair of customer and payment method. Yuno reassigns the payment method to the new customer, but it does not update those references on the merchant side.
</Warning>


## OpenAPI

````yaml openapi/payment-methods-direct-workflow/reassign-payment-method-api.json PATCH /payment-methods/{payment_method_id}
openapi: 3.1.0
info:
  title: customer-api
  version: 1.0.0
servers:
  - url: https://api-sandbox.y.uno/v1
security:
  - sec0: []
    sec1: []
paths:
  /payment-methods/{payment_method_id}:
    patch:
      summary: Reassign a Payment Method to Another Customer
      description: >-
        Reassigns an enrolled payment method to a different customer of the same
        account. Only card payment methods can be reassigned. The reassignment
        fails when the payment method is already assigned to a customer that has
        data. Returns the payment method in the same shape as the Enroll Payment
        Method response, with the new owner in the `customer_id` field.
      operationId: reassign-payment-method-api
      parameters:
        - name: payment_method_id
          in: path
          description: >-
            The unique identifier of the `payment_method`. This is the
            `vaulted_token` received when enrolling a payment method with
            [Enroll Payment Method](/reference/enroll-payment-method-api)
            (UUID).
          schema:
            type: string
          required: true
        - name: X-account-code
          in: header
          description: The unique identifier of your account (UUID).
          schema:
            type: string
            x-default: <Your X-account-code>
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReassignPaymentMethodInput'
            example:
              customer_id: b3f2c1a0-1234-4a5b-9c8d-000000000001
      responses:
        '200':
          description: >-
            The reassigned payment method, including the new owner in the
            `customer_id` field.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentMethod'
              example:
                idempotency_key: a0000000-0000-4000-8000-000000000010
                name: VISA ****1111
                description: VISA ****1111
                type: CARD
                category: CARD
                country: US
                parent_type: null
                status: ENROLLED
                sub_status: ENROLLED
                vaulted_token: b0000000-0000-4000-8000-000000000002
                callback_url: null
                action: null
                redirect_url: null
                created_at: '2024-06-04T12:47:46.992602Z'
                updated_at: '2024-06-04T12:47:46.992603Z'
                card_data:
                  iin: '41111111'
                  lfd: '1111'
                  holder_name: JOHN DOE
                  expiration_month: 3
                  expiration_year: 26
                  number_length: 16
                  security_code_length: 3
                  brand: VISA
                  issuer: JPMORGAN CHASE BANK N A
                  issuer_code: null
                  country_code: US
                  category: CREDIT
                  type: CREDIT
                  fingerprint: 55a7fe38-cdc3-45dc-8c5f-820751799c76
                last_successfully_used: null
                last_successfully_used_at: null
                preferred: null
                customer_id: b3f2c1a0-1234-4a5b-9c8d-000000000001
                verify: null
        '400':
          description: >-
            The request is invalid, the target customer does not exist, or the
            payment method is not a card.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestError'
              examples:
                Missing customer_id:
                  value:
                    code: INVALID_PARAMETERS
                    messages:
                      - The field 'customer_id' is required.
                Invalid customer_id:
                  value:
                    code: INVALID_PARAMETERS
                    messages:
                      - The field 'customer_id' must be a valid uuid v4.
                Malformed request body:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - Bad request
                Target customer does not exist:
                  value:
                    code: CUSTOMER_NOT_FOUND
                    messages:
                      - Customer not found.
                Payment method is not a card:
                  value:
                    code: PAYMENT_METHOD_NOT_REASSIGNABLE
                    messages:
                      - Only card payment methods can be reassigned.
        '404':
          description: The payment method does not exist for this account.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentMethodNotFoundError'
              examples:
                Payment method not found:
                  value:
                    code: PAYMENT_METHOD_NOT_FOUND
                    messages:
                      - Payment method not found.
        '409':
          description: The payment method is already assigned to a customer that has data.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentMethodConflictError'
              examples:
                Already assigned to a customer with data:
                  value:
                    code: CONFLICT
                    messages:
                      - >-
                        payment_method is already assigned to a customer with
                        data
      deprecated: false
components:
  schemas:
    ReassignPaymentMethodInput:
      type: object
      required:
        - customer_id
      properties:
        customer_id:
          type: string
          description: >-
            The unique identifier of the customer the payment method is
            reassigned to (UUID). The payment method can be reassigned only
            while its current customer has no data; otherwise the request
            returns `409 CONFLICT`.
    PaymentMethod:
      type: object
      properties:
        idempotency_key:
          type: string
          example: a0000000-0000-4000-8000-000000000010
        name:
          type: string
          example: VISA ****1111
        description:
          type: string
          example: VISA ****1111
        type:
          type: string
          example: CARD
        category:
          type: string
          example: CARD
        country:
          type: string
          example: US
        parent_type: {}
        status:
          type: string
          example: ENROLLED
        sub_status:
          type: string
          example: ENROLLED
        vaulted_token:
          type: string
          example: b0000000-0000-4000-8000-000000000002
        callback_url: {}
        action: {}
        redirect_url: {}
        created_at:
          type: string
          example: '2024-06-04T12:47:46.992602Z'
        updated_at:
          type: string
          example: '2024-06-04T12:47:46.992603Z'
        card_data:
          type: object
          properties:
            iin:
              type: string
              example: '41111111'
            lfd:
              type: string
              example: '1111'
            holder_name:
              type: string
              description: Cardholder's full name as returned by the payment provider.
              example: JOHN DOE
            expiration_month:
              type: integer
              example: 3
              default: 0
            expiration_year:
              type: integer
              example: 26
              default: 0
            number_length:
              type: integer
              example: 16
              default: 0
            security_code_length:
              type: integer
              example: 3
              default: 0
            brand:
              type: string
              example: VISA
            issuer:
              type: string
              example: JPMORGAN CHASE BANK N A
            issuer_code: {}
            country_code:
              type: string
              description: ISO 3166-1 alpha-2 country code of the card's issuing country.
              example: US
            category:
              type: string
              example: CREDIT
            type:
              type: string
              example: CREDIT
            fingerprint:
              type: string
              example: 55a7fe38-cdc3-45dc-8c5f-820751799c76
        last_successfully_used: {}
        last_successfully_used_at: {}
        preferred: {}
        customer_id:
          type: string
          description: >-
            The unique identifier of the customer the payment method now belongs
            to. Returned by the reassignment response so you can confirm the new
            owner.
          example: b3f2c1a0-1234-4a5b-9c8d-000000000001
        verify: {}
    BadRequestError:
      type: object
      properties:
        code:
          type: string
          description: Machine-readable error code.
          enum:
            - INVALID_PARAMETERS
            - BAD_REQUEST
            - CUSTOMER_NOT_FOUND
            - PAYMENT_METHOD_NOT_REASSIGNABLE
        messages:
          type: array
          description: Human-readable description of the error.
          items:
            type: string
    PaymentMethodNotFoundError:
      type: object
      properties:
        code:
          type: string
          description: Machine-readable error code.
          enum:
            - PAYMENT_METHOD_NOT_FOUND
        messages:
          type: array
          description: Human-readable description of the error.
          items:
            type: string
    PaymentMethodConflictError:
      type: object
      properties:
        code:
          type: string
          description: Machine-readable error code.
          enum:
            - CONFLICT
        messages:
          type: array
          description: Human-readable description of the error.
          items:
            type: string
  securitySchemes:
    sec0:
      type: apiKey
      in: header
      name: public-api-key
      x-default: <Your public-api-key>
    sec1:
      type: apiKey
      in: header
      name: private-secret-key
      x-default: <Your private-secret-key>

````