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

# Update a Card Registration

This call is used to add the string acquired from the tokenization to the Card Registration object in the parameter `RegistrationData`, thereby validating the registration.

As a result, the Card object is created and the corresponding `CardId` returned.

Platforms should also send the cardholder’s name as it appears on the payment card. The `CardHolderName` parameter is sent on this call but not returned in the response; it is added to the Card object.

### Path parameters

<ParamField path="CardRegistrationId" type="string" required>
  The unique identifier of the Card Registration object.
</ParamField>

### Body parameters

<ParamField body="RegistrationData" type="string" required>
  The string returned by the tokenization server on the <a href="/api-reference/card-registrations/tokenize-card">POST Tokenize the card</a> endpoint.
</ParamField>

<ParamField body="CardHolderName" type="string">
  Min. length: 2 characters; max. length: 45 characters passed to card network, 255 accepted by the API

  The cardholder's name shown on the payment card. This value is passed to the card network for use in transaction risk analysis.

  The value should only contain unmarked alphabetic characters (A-Z, a-z), hyphens (-), apostrophes (‘), and spaces. Letters with diacritics (e.g. É, Ü, ẞ), honorifics (e.g. MRS.) and other special characters are not recommended.

  The `CardHolderName` is not returned in the Card Registration object; it is added to the Card object.
</ParamField>

### Responses

<AccordionGroup>
  <Accordion title="200 - Status &#x22;VALIDATED&#x22;">
    <ResponseField name="Id" type="string">
      The unique identifier of the Card Registration object.
    </ResponseField>

    <ResponseField name="Tag" type="string">
      Custom data that can be added to this object.\
      In the case of the Card Registration, this parameter can be used to facilitate the link between the User object and its equivalent on your platform for instance. This value will be inherited by the Card object `Tag` parameter and will not be editable.
    </ResponseField>

    <ResponseField name="CreationDate" type="Unix timestamp">
      The date and time at which the object was created.
    </ResponseField>

    <ResponseField name="UserId" type="string">
      The unique identifier of the user the card belongs to.
    </ResponseField>

    <ResponseField name="AccessKey" type="string">
      The secure value to use when tokenizing the card via the dedicated endpoint.
    </ResponseField>

    <ResponseField name="PreregistrationData" type="string">
      The secure value to identify the registration when tokenizing the card via the dedicated endpoint.
    </ResponseField>

    <ResponseField name="RegistrationData" type="string">
      The string returned by the tokenization server, which must be sent in full as the `RegistrationData` on the <a href="/api-reference/card-registrations/update-card-registration">PUT Update a Card Registration</a> endpoint to create the Card object.
    </ResponseField>

    <ResponseField name="CardId" type="string">
      The unique identifier of the Card object, which is returned after updating the Card Registration object with the `RegistrationData`.
    </ResponseField>

    <ResponseField name="CardType" type="string">
      **Returned values:** `CB_VISA_MASTERCARD`, `AMEX`, `MAESTRO`, `BCMC`

      **Default value:** `CB_VISA_MASTERCARD`

      The type of the card. If not supplied, the default value will be taken into account.
    </ResponseField>

    <ResponseField name="CardRegistrationURL" type="string">
      The URL to make the card tokenization call.

      **Caution:** This variable URL is specific to each card registration. You must rely on the returned URL in full (host, path, and queries) and not hardcode any part of it.
    </ResponseField>

    <ResponseField name="ResultCode" type="string">
      The code indicating the result of the operation. This information is mostly used to <a href="/errors/codes">handle errors</a> or for filtering purposes.
    </ResponseField>

    <ResponseField name="ResultMessage" type="string">
      The explanation of the result code.
    </ResponseField>

    <ResponseField name="Currency" type="string">
      **Returned values:** The three-letter <a href="/api-reference/overview/data-formats" target="_blank">ISO 4217 code</a> (EUR, GBP, etc.) of a <a href="/guides/currencies" target="_blank">supported currency</a> (depends on feature, contract, and activation settings).

      The currency of the card.
    </ResponseField>

    <ResponseField name="Status" type="string">
      **Returned values:** `CREATED`, `VALIDATED`, `ERROR`

      The status of the card registration:

      * `CREATED` – The card registration has been created, but no `RegistrationData` has been entered yet and the `CardId` value is `null`.
      * `VALIDATED` – The card registration has been successfully updated with the `RegistrationData` from the tokenization server.
      * `ERROR` – The card registration couldn’t be updated with the `RegistrationData` and no `CardId` was generated. For more information, refer to the `ResultCode` (<a href="/errors/codes/105206">105206</a>, <a href="/errors/codes/105299">105299</a>) and `ResultMessage`.
    </ResponseField>
  </Accordion>

  <Accordion title="200 - Status &#x22;ERROR&#x22;">
    <ResponseField name="Id" type="string">
      The unique identifier of the Card Registration object.
    </ResponseField>

    <ResponseField name="Tag" type="string">
      Custom data that can be added to this object.\
      In the case of the Card Registration, this parameter can be used to facilitate the link between the User object and its equivalent on your platform for instance. This value will be inherited by the Card object `Tag` parameter and will not be editable.
    </ResponseField>

    <ResponseField name="CreationDate" type="Unix timestamp">
      The date and time at which the object was created.
    </ResponseField>

    <ResponseField name="UserId" type="string">
      The unique identifier of the user the card belongs to.
    </ResponseField>

    <ResponseField name="AccessKey" type="string">
      The secure value to use when tokenizing the card via the dedicated endpoint.
    </ResponseField>

    <ResponseField name="PreregistrationData" type="string">
      The secure value to identify the registration when tokenizing the card via the dedicated endpoint.
    </ResponseField>

    <ResponseField name="RegistrationData" type="string">
      The string returned by the tokenization server, which must be sent in full as the `RegistrationData` on the <a href="/api-reference/card-registrations/update-card-registration">PUT Update a Card Registration</a> endpoint to create the Card object.
    </ResponseField>

    <ResponseField name="CardId" type="string">
      The unique identifier of the Card object, which is returned after updating the Card Registration object with the `RegistrationData`.
    </ResponseField>

    <ResponseField name="CardType" type="string">
      **Returned values:** `CB_VISA_MASTERCARD`, `AMEX`, `MAESTRO`, `BCMC`

      **Default value:** `CB_VISA_MASTERCARD`

      The type of the card. If not supplied, the default value will be taken into account.
    </ResponseField>

    <ResponseField name="CardRegistrationURL" type="string">
      The URL to make the card tokenization call.

      **Caution:** This variable URL is specific to each card registration. You must rely on the returned URL in full (host, path, and queries) and not hardcode any part of it.
    </ResponseField>

    <ResponseField name="ResultCode" type="string">
      The code indicating the result of the operation. This information is mostly used to <a href="/errors/codes">handle errors</a> or for filtering purposes.
    </ResponseField>

    <ResponseField name="ResultMessage" type="string">
      The explanation of the result code.
    </ResponseField>

    <ResponseField name="Currency" type="string">
      **Returned values:** The three-letter <a href="/api-reference/overview/data-formats" target="_blank">ISO 4217 code</a> (EUR, GBP, etc.) of a <a href="/guides/currencies" target="_blank">supported currency</a> (depends on feature, contract, and activation settings).

      The currency of the card.
    </ResponseField>

    <ResponseField name="Status" type="string">
      **Returned values:** `CREATED`, `VALIDATED`, `ERROR`

      The status of the card registration:

      * `CREATED` – The card registration has been created, but no `RegistrationData` has been entered yet and the `CardId` value is `null`.
      * `VALIDATED` – The card registration has been successfully updated with the `RegistrationData` from the tokenization server.
      * `ERROR` – The card registration couldn’t be updated with the `RegistrationData` and no `CardId` was generated. For more information, refer to the `ResultCode` (<a href="/errors/codes/105206">105206</a>, <a href="/errors/codes/105299">105299</a>) and `ResultMessage`.
    </ResponseField>
  </Accordion>
</AccordionGroup>

<Accordion title="400 - CardHolderName can't be longer than than 255 characters">
  ```json theme={null}
  {
      "Message": "One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.",
      "Type": "param_error",
      "Id": "a241d282-377f-4415-ab81-5dc11c63f972",
      "Date": 1723543647.0,
      "errors": {
          "CardHolderName": "The field CardHolderName must be between 2 and 255 characters long."
      }
  }
  ```
</Accordion>

<ResponseExample>
  ```json 200 theme={null}
  {
      "Id": "cardreg_wt_11ed4694-d244-4bd1-92fb-dc473c99a9d4",
      "Tag": null,
      "CreationDate": 1726239226,
      "UserId": "user_m_01J7KACBPAV7XAF8AH9BDCJPRS",
      "AccessKey": "ehvrHoPE6FpjCCAgmNvg",
      "PreregistrationData": "lhOJ6CFiDJPCXViyHjfcayh92nouB3AAaB5yqiLCBT6yjkLPCptmxsUdfffAc6EE4uj9AuSfmwbdfKN3BMechzUU3Gz8ectEx70TDeupudr",
      "RegistrationData": "data=acIcnwwLleiAvlZUea5VxYT1eCIn3MER8jyZXr-p8Bzb4Rm8GIA0MQtPs2NL7zPzPO_I7EjQm-m92V909JUL6KT-PmPzJfAQZV_8PIz6wKvjorGNaNd8Mg1rqN6eBpS5Nx0xgKTVnyDj15oG8jR875",
      "CardId": "card_m_NioQspdYckEoRlzd",
      "CardType": "CB_VISA_MASTERCARD",
      "CardRegistrationURL": "https://pci.sandbox.mangopay.com/api/mangopay/vault/tokenize/eyJjbGllbnQiOiJhbnRob255aF90ZXN0MSIsInRva2VuIjoiUlBQTVdJR1hrd0ZJSGFacyJ9",
      "ResultCode": "000000",
      "ResultMessage": "Success",
      "Currency": "EUR",
      "Status": "VALIDATED"
  }
  ```
</ResponseExample>

<RequestExample>
  ```python cURL theme={null}
  curl -X PUT https://api.sandbox.mangopay.com/v2.01/{ClientId}/cardregistrations/{CardRegistrationId} \
    -H 'Content-Type: application/json' \
    -d '{
      "RegistrationData": "data=acIcnwwLleiAvlZUea5VxZlDBkf07H6B9-N7SrRv5Vv7oSLc1hhCdoFX4JxfZL2iUkLIQL3o9ehAOeaXCbc1KFWnr4ySDvkZ--mJxxdF-vw-gzLNe3lvG2loJvmwrDyRNx0xgKTVnyDj15oG8jR88g",
      "CardHolderName": "Alex Smith"
  }'
  ```

  ```json REST   theme={null}
  {
      "RegistrationData": "data=acIcnwwLleiAvlZUea5VxZlDBkf07H6B9-N7SrRv5Vv7oSLc1hhCdoFX4JxfZL2iUkLIQL3o9ehAOeaXCbc1KFWnr4ySDvkZ--mJxxdF-vw-gzLNe3lvG2loJvmwrDyRNx0xgKTVnyDj15oG8jR88g",
      "CardHolderName": "Alex Smith"
  }  
  ```

  ```php PHP theme={null}
  <?php 

  require_once 'vendor/autoload.php';

  use MangoPay\MangoPayApi;
  use MangoPay\Libraries\ResponseException as MGPResponseException;
  use MangoPay\Libraries\Exception as MGPException;

  $api = new MangoPayApi();

  $api->Config->ClientId = 'your-client-id';
  $api->Config->ClientPassword = 'your-api-key';
  $api->Config->TemporaryFolder = 'tmp/';

  try {
      $cardRegistration = new \MangoPay\CardRegistration();

      $cardRegistration->Id = '198660792';
      $cardRegistration->RegistrationData = 'data=EwQibNkLWbGepaBektTHQcnk7KxDDpQybRm3BWmKLu4DKdgmC-JI0b4bK9UW5C3u1L4A4AkhT3LJqC3_FAvbwYQXIPvj1ElxL2OIJfvlS3YXlJyOctdX1PGkkgCkgl3j0ftIYwFxOdfmDQ5GtM_cIg';

      $response = $api->CardRegistrations->Update($cardRegistration);

      print_r($response);
  } catch(MGPResponseException $e) {
      print_r($e);
  } catch(MGPException $e) {
      print_r($e);
  }  
  ```

  ```javascript NodeJS   theme={null}
  const mangopayInstance = require('mangopay4-nodejs-sdk');
  const mangopay = new mangopayInstance({
      clientId: "your-client-id",
      clientApiKey: "your-api-key",
  })

  let user = {
      Id: 'user_m_01HQK25M6KVHKDV0S36JY9NRKR',
    }

  let userCardRegistration = {
      Id: 'cardreg_m_01HRETW28RKJFC8RB9H625RVBD',
      UserId: user.Id,
      Currency: 'EUR',
      CardType: 'CB_VISA_MASTERCARD',
      RegistrationData: 'data=acIcnwwLleiAvlZUea5VxT5mw_fK696E0m-dvIdK-KnTCrftajOU7W3fTvYLnKiF68q7RUkmAEL86Wi8c0oX7wHD6vfA3lowMRD7SvlcCCl6Xl3Esy_DIyBzznraJzm70ftIYwFxOdfmDQ5GtM_cIg',
      CardHolderName: 'Alex Smith',
  }

  const updateCardRegistration = async(cardRegistration) => {
      return await mangopay.CardRegistrations.update(cardRegistration)
      .then((response) => {
          console.info(response)
          return response
      })
      .catch((err) => {
          console.log(err)
          return false
      })
  }

  updateCardRegistration(userCardRegistration)  
  ```

  ```ruby Ruby   theme={null}
  require 'mangopay'

  MangoPay.configure do |client|
      client.preproduction = true
      client.client_id = 'your-client-id'
      client.client_apiKey = 'your-api-key'
      client.log_file = File.join(Dir.pwd, 'mangopay.log')
  end

  def updateCardRegistration(card_registration_id, params)
      begin
          response = MangoPay::CardRegistration.update(card_registration_id, params)
          puts response
          return response
      rescue MangoPay::ResponseError => error
          puts "Failed : #{error.message}"
          puts "Error details: #{error.details}"
          return false
      end
  end

  params = {
      "RegistrationData": "data=acIcnwwLleiAvlZUea5VxW4I8X8iCT0M1Z4j5kgkKf4KQzh0G0UQLpozaVZwyqUOQJM3kYVZIDlCIp6vDysQ6F0qIb1486gpwf_EGW9fTllJlstGZZo5YuZ8RWz_814ONx0xgKTVnyDj15oG8jR88g",
      "CardHolderName": "ALEX SMITH"
  }

  updateCardRegistration("cardreg_m_01J2C8JM4YHV1Z57RKRBK97B0Y", params)
  ```

  ```java Java  theme={null}
  import com.google.gson.Gson;
  import com.google.gson.GsonBuilder;
  import com.mangopay.MangoPayApi;
  import com.mangopay.entities.CardRegistration;

  public class UpdateCardRegistration {
      public static void main(String[] args) throws Exception {
          MangoPayApi mangopay = new MangoPayApi();
      	  mangopay.getConfig().setClientId("your-client-id");
     	  mangopay.getConfig().setClientPassword("your-api-key");

          CardRegistration cardReg = mangopay.getCardRegistrationApi().get("cardreg_m_01HXY9VZN4J1TERYG1BNPDHENN");
          cardReg.setRegistrationData("data=acIcnwwLleiAvlZUea5VxfRSGv9nDzXcMqBpL3byXCz_GKPvDDem-KDL6Tf_yaRZBYWP-ghC9O56GivqHUjmwR4Dq2M_FO0KhF_NWnd-fb5L_0I49NvwmWI1uPP5WuzcNx0xgKTVnyDj15oG8jR88g");

          CardRegistration updateCardRegistration = mangopay.getCardRegistrationApi().update(cardReg);

          Gson prettyPrint = new GsonBuilder().setPrettyPrinting().create();
          String prettyJson = prettyPrint.toJson(updateCardRegistration);

          System.out.println(prettyJson);
      }
  }
  ```

  ```python Python   theme={null}
  from pprint import pprint
  import mangopay

  mangopay.client_id='your-client-id'
  mangopay.apikey='your-api-key'

  from mangopay.api import APIRequest
  handler = APIRequest(sandbox=True)

  from mangopay.resources import CardRegistration

  user_card_registration = CardRegistration(
     id = '213600973',
     registration_data = 'data=R7hxMYui4h4rBkaNwbiH1DvQL35Y-goFSYQI384_jNsDngV32O95BVgk3Pg7vqU_mZIFFs4gFl24VlSBXNiuoi4Be_uieN3jEegz77g8ElaToz_b7S91YuROvHH0w6J40ftIYwFxOdfmDQ5GtM_cIg',
     card_holder_name = 'Alex Smith'
  )

  update_card_registration = user_card_registration.save()

  pprint(update_card_registration)  
  ```

  ```csharp .NET  theme={null}
  using MangoPay.SDK;
  using MangoPay.SDK.Entities.PUT;
  using Newtonsoft.Json;

  class Program
  {
      static async Task Main(string[] args)
      {
          MangoPayApi api = new MangoPayApi();

          api.Config.ClientId = "your-client-id";
          api.Config.ClientPassword = "your-api-key";

          var cardRegistrationId = "cardreg_m_01J2Y3ZTFTZSKB5XWAKCNMPWFC";
          var registrationData = "data=qc_ShKapgXF-A2t_OC72Ktbe2pgMGnalwOa7YhCbIDdpW0cgKABxbhU6R6yVTVJKZpvPpkvQy0HS6G3zrpUyXboAD2d1WLU2-FKrT2dHpcH9c8YxZgpdCs4Z6c6u-qDT0ftIYwFxOdfmDQ5GtM_cIg";

          var cardRegistration = new CardRegistrationPutDTO
          {
              RegistrationData = registrationData,
              Tag = "Updated using the Mangopay .NET SDK"
          };

          var updateCardRegistration = await api.CardRegistrations.UpdateAsync(cardRegistration, cardRegistrationId);

          string prettyPrint = JsonConvert.SerializeObject(updateCardRegistration, Formatting.Indented);
          Console.WriteLine(prettyPrint);
      }
  }
  ```
</RequestExample>
