Inicio
Documentación
Recursos
Certificaciones
Comunidad

Recursos

Revisa las actualizaciones de nuestras soluciones y operatividad del sistema o pide soporte técnico.

Comunidad

Recibe las últimas novedades, pide ayuda a otros integradores y comparte tus conocimientos.

Modificar cliente - Gestión de tarjetas y clientes - Mercado Pago Developers

Búsqueda inteligente powered by OpenAI 

Modificar cliente

Si se produce un cambio en los datos de un cliente, como por ejemplo la dirección, la tarjeta o el email de la cuenta, es posible realizar esta alteración a través de la API de clientes o de nuestros SDKs.

En la siguiente tabla se describen todos los atributos que se pueden modificar, y para realizar el cambio, envía un PUT con el customer_id y los atributos que deseas modificar al endpoint /v1/customers/{id} y ejecuta la solicitud o, si lo prefieres, utiliza uno de los siguientes SDKs.

Importante
Si no tienes el customer_id, sigue los pasos indicados en la sección Buscar cliente para obtener la información. Además, el campo email solo puede actualizarse si el cliente aún no tiene un email asociado.
AtributoDescripción
addressDirección
default_addressDirección estándar
default_cardTarjeta estándar
descriptionDescripción
emaiEmail de la cuenta
first_nameNombre
last_nameApellido
phoneTeléfono registrado
identificationTipo y número del documento
          
<?php
  MercadoPagoConfig::setAccessToken("YOUR_ACCESS_TOKEN");
  
  $client = new CustomerClient();

  $customer = $client->update("user_id", [
    "email" => "[email protected]",
    "first_name" => "john",
    "last_name" => "wagner",
    "phone" => array(
      "area_code" => "11",
      "number" => "001234567"
    ),
    "identification" => array(
      "type" => "CPF",
      "number" => "12341234"
    ),
    "default_address" => "Casa",
    "address" => array(
      "zip_code" => "52",
      "street_name" => "Av. das Nações Unidas"
      "street_number" => "3033"
    )
  ]);
?>

        
          
const client = new MercadoPagoConfig({ accessToken: 'YOUR_ACCESS_TOKEN' });
const customer = new Customer(client);

const body = {
  email: "[email protected]"
  first_name: "john",
  last_name: "wagner",
  phone: {
    area_code: "11",
    number: "001234567"
  }
  identification: {
    type: "CPF",
    number: "12341234"
  },
  default_address: "Casa",
  address: {
    zip_code: "52",
    street_name: "Av. das Nações Unidas"
    street_number: "3033"
  }
};

customer.update({ customerId: '<CUSTOMER_ID>', body: body,
}).then(console.log).catch(console.log);

        
          
MercadoPagoConfig.setAccessToken("ENV_ACCESS_TOKEN");

CustomerClient client = new CustomerClient();

CustomerRequest request = CustomerRequest.builder()
   .email("[email protected]")
   .firstName("John")
   .lastName("Wagner")
   .defaultAddress("Casa")
   .phone(PhoneRequest.builder()
       .areaCode("11")
       .number("001234567")
       .build())
   .identification(IdentificationRequest.builder()
       .type("CPF")
       .number("12341234")
       .build())
   .description("Información del cliente")
   .defaultCard("None")
   .address(CustomerAddressRequest.builder()
       .zipCode("52")
       .streetName("Av. Caseros")
       .streetNumber(2)
       .build())
   .build();

client.update("247711297-jxOV430go9fx2e", request);


        
          
require 'mercadopago'

sdk = Mercadopago::SDK.new('ENV_ACCESS_TOKEN')

customer_request = {
  email: '[email protected]',
  first_name: 'john',
  last_name: 'wagner',
  default_address: 'Casa',
  phone: {
    area_code: '11',
    number: '001234567'
  },
  identification: {
    type: 'CI',
    number: '12341234'
  },
  address: {
    zip_code: '52',
    street_name: 'Av Libertador Lavalleja',
    street_number: '2'
  },
  description: 'Información del cliente',
  default_card: 'None'
}
customer_response = sdk.customer.update(customer_id ,customer_request)
customer = customer_response[:response]


        
          
MercadoPagoConfig.AccessToken = "ENV_ACCESS_TOKEN";
var phoneRequest = new PhoneRequest
{
  AreaCode = "11",
  Number = "001234567"
};

var identificationRequest = new IdentificationRequest
{
  Type = "CI",
  Number = "12341234"
};

var addressRequest = new AddressRequest
{
  ZipCode = "52",
  StreetName = "Av Libertador Lavalleja",
  StreetNumber = "2"
};

var customerRequest = new CustomerRequest
{
    Email = "[email protected]",
    FirstName = "john",
    LastName = "wagner",
    DefaultAddress = "home",
    Description = "Información del cliente",
    DefaultCard = "None",
    Phone = phoneRequest,
    Identification = identificationRequest,
    Address = addressRequest

};
var customerClient = new CustomerClient();
Customer customer = await customerClient.Update(customerRequest);


        
          
import mercadopago
sdk = mercadopago.SDK("ENV_ACCESS_TOKEN")

customer_data = {
  "email": '[email protected]',
  "first_name": 'john',
  "last_name": 'wagner',
  "default_address": 'Casa',
  "phone": {
    "area_code": '11',
    "number": '001234567'
  },
  "identification": {
    "type": 'CI',
    "number": '12341234'
  },
  "address": {
    "zip_code": '52',
    "street_name": 'Av Libertador Lavalleja',
    "street_number": '2'
  },
  "description": 'Información del cliente',
  "default_card": 'None'
}
customer_response = sdk.customer().update(customer_id, customer_data)
customer = customer_response["response"]


        
          
package main

import (
	"context"
	"fmt"

	"github.com/mercadopago/sdk-go/pkg/config"
	"github.com/mercadopago/sdk-go/pkg/customer"
)

func main() {
	accessToken := "{{ACCESS_TOKEN}}"

	cfg, err := config.New(accessToken)
	if err != nil {
		fmt.Println(err)
		return
	}

	client := customer.NewClient(cfg)

	request := customer.Request{
		Email: "[email protected]",
		FirstName: "John",
		LastName: "Wagner",
		DefaultAddress: "Casa",
		Phone: &customer.PhoneRequest{
			AreaCode: "11",
			Number: "001234567",
		},
		Identification: &customer.IdentificationRequest{
			Type: "CPF",
			Number: "12341234",
		},
		Address: &customer.AddressRequest{
			ZipCode: "52",
			StreetName: "Av. das Nações Unidas",
			StreetNumber: "2",
		},
		Description: "Updated Description",
		DefaultCard: "None",
	}

	resource, err := client.Update(context.Background(), "<CUSTOMER_ID>", request)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(resource)
}

        
          
curl -X PUT \
    'https://api.mercadopago.com/v1/customers/{id}' \
    -H 'Authorization: Bearer ACCESS_TOKEN_ENV' \ 
    -d '{
  "email": "[email protected]",
  "first_name": "john",
  "last_name": "wagner",
  "address": {
    "zip_code": "52",
    "street_name": "Av Libertador Lavalleja",
    "street_number": "2"
  },
  "phone": {
    "area_code": "11",
    "number": "001234567"
  },
  "identification": {
    "type": "CI",
    "number": "12341234"
  },
  "description": "Información del cliente" 
}'


        

Ejemplo de respuesta con el envío del customer_id:

json

{
  "id": "xxxxxxxxxxxxxxxxxxxxx",
  "email": "[email protected]",
  "first_name": "john",
  "last_name": "wagner",
  "phone": {
    "area_code": "11",
    "number": 001234567
  },
  "identification": {
    "type": "CI",
    "number": 12341234
  },
  "address": {
    "zip_code": "52",
    "street_name": "Av Libertador Lavalleja",
    "street_number": 2
  },
  "description": "Informações do cliente",
  "date_created": "2021-05-25T15:36:23.541Z",
  "metadata": {},
  "cards": [
    {}
  ],
  "addresses": [
    {}
  ]
}

Ejemplo de respuesta sin el parámetro customer_id:

json

{
  "message": "missing customer id"
}