cURL
curl --request PATCH \ --url http://api.gu1.ai/entities/{id} \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data ' { "entityData": { "paymentMethod": {} }, "relationships": [ {} ], "metadata": {} } '
{ "success": true, "id": "<string>", "entityType": "<string>", "entityData": {}, "relationships": [ {} ], "metadata": {}, "updatedAt": "<string>" }
Update a payment method entity
PATCH http://api.gu1.ai/entities/{id}
Authorization: Bearer YOUR_API_KEY
Show properties
curl -X PATCH "http://api.gu1.ai/entities/payment-method-uuid-123" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "entityData": { "paymentMethod": { "expiryMonth": "06", "expiryYear": "2026" } } }'
curl -X PATCH "http://api.gu1.ai/entities/payment-method-uuid-123" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "entityData": { "paymentMethod": { "fingerprint": "abc123xyz456" } } }'
curl -X PATCH "http://api.gu1.ai/entities/payment-method-uuid-123" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "entityData": { "paymentMethod": { "holderName": "Jane Smith" } } }'
curl -X PATCH "http://api.gu1.ai/entities/payment-method-uuid-123" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "metadata": { "isDefault": true, "addedVia": "mobile_app", "verifiedAt": "2024-12-23T10:00:00Z" } }'
"payment_method"
{ "success": true, "id": "payment-method-uuid-123", "entityType": "payment_method", "entityData": { "paymentMethod": { "type": "credit_card", "last4": "4242", "brand": "visa", "expiryMonth": "06", "expiryYear": "2026", "holderName": "John Doe", "issuerCountry": "BR", "bin": "424242", "funding": "credit", "fingerprint": "abc123xyz456" } }, "relationships": [ { "targetEntityId": "person-uuid-123", "relationshipType": "owns", "strength": 1.0 } ], "metadata": { "isDefault": true, "addedVia": "mobile_app", "verifiedAt": "2024-12-23T10:00:00Z" }, "createdAt": "2024-01-15T10:00:00.000Z", "updatedAt": "2024-12-23T10:15:00.000Z" }
async function updateExpiredCard(paymentMethodId, newExpiry) { const response = await fetch( `http://api.gu1.ai/entities/${paymentMethodId}`, { method: 'PATCH', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ entityData: { paymentMethod: { expiryMonth: newExpiry.month, expiryYear: newExpiry.year } }, metadata: { updatedReason: 'card_renewal', updatedAt: new Date().toISOString() } }) } ); return await response.json(); } // Usage await updateExpiredCard('payment-method-uuid-123', { month: '12', year: '2027' });
async function setDefaultPaymentMethod(personId, paymentMethodId) { // First, remove default flag from all other payment methods const listResponse = await fetch( `http://api.gu1.ai/entities?entityType=payment_method&relationshipWith=${personId}`, { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } } ); const { entities } = await listResponse.json(); // Update all to not default await Promise.all( entities.map(pm => fetch(`http://api.gu1.ai/entities/${pm.id}`, { method: 'PATCH', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ metadata: { isDefault: false } }) }) ) ); // Set new default const response = await fetch( `http://api.gu1.ai/entities/${paymentMethodId}`, { method: 'PATCH', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ metadata: { isDefault: true } }) } ); return await response.json(); }
async function markPaymentMethodVerified(paymentMethodId, verificationData) { const response = await fetch( `http://api.gu1.ai/entities/${paymentMethodId}`, { method: 'PATCH', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ metadata: { verified: true, verifiedAt: new Date().toISOString(), verificationMethod: verificationData.method, verificationId: verificationData.id } }) } ); return await response.json(); }
{ "error": "Entity not found", "entityId": "payment-method-uuid-123" }
{ "error": "Invalid update data", "details": { "entityData.paymentMethod.expiryMonth": "Must be between 01 and 12" } }
{ "error": "Invalid or missing API key" }
null
updatedAt
Was this page helpful?