Create account card
curl --request POST \
--url https://sandbox-api.marqeta.com/v3/credit/accounts/{account_token}/cards \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"user_token": "user1234",
"card_product_token": "my-card-product1234"
}
'import requests
url = "https://sandbox-api.marqeta.com/v3/credit/accounts/{account_token}/cards"
payload = {
"user_token": "user1234",
"card_product_token": "my-card-product1234"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({user_token: 'user1234', card_product_token: 'my-card-product1234'})
};
fetch('https://sandbox-api.marqeta.com/v3/credit/accounts/{account_token}/cards', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox-api.marqeta.com/v3/credit/accounts/{account_token}/cards",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user_token' => 'user1234',
'card_product_token' => 'my-card-product1234'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox-api.marqeta.com/v3/credit/accounts/{account_token}/cards"
payload := strings.NewReader("{\n \"user_token\": \"user1234\",\n \"card_product_token\": \"my-card-product1234\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://sandbox-api.marqeta.com/v3/credit/accounts/{account_token}/cards")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"user_token\": \"user1234\",\n \"card_product_token\": \"my-card-product1234\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox-api.marqeta.com/v3/credit/accounts/{account_token}/cards")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_token\": \"user1234\",\n \"card_product_token\": \"my-card-product1234\"\n}"
response = http.request(request)
puts response.read_body{
"token": "my_credit_card_token1234",
"user_token": "user1234",
"created_time": "2024-09-03T19:39:53.719Z",
"updated_time": "2024-09-03T19:39:53.719Z",
"account_token": "my_account_token_12"
}{
"code": 123,
"message": "<string>"
}Account Cards
Create account card
Create a credit card for an existing credit account.
POST
/
credit
/
accounts
/
{account_token}
/
cards
Create account card
curl --request POST \
--url https://sandbox-api.marqeta.com/v3/credit/accounts/{account_token}/cards \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"user_token": "user1234",
"card_product_token": "my-card-product1234"
}
'import requests
url = "https://sandbox-api.marqeta.com/v3/credit/accounts/{account_token}/cards"
payload = {
"user_token": "user1234",
"card_product_token": "my-card-product1234"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({user_token: 'user1234', card_product_token: 'my-card-product1234'})
};
fetch('https://sandbox-api.marqeta.com/v3/credit/accounts/{account_token}/cards', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox-api.marqeta.com/v3/credit/accounts/{account_token}/cards",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user_token' => 'user1234',
'card_product_token' => 'my-card-product1234'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox-api.marqeta.com/v3/credit/accounts/{account_token}/cards"
payload := strings.NewReader("{\n \"user_token\": \"user1234\",\n \"card_product_token\": \"my-card-product1234\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://sandbox-api.marqeta.com/v3/credit/accounts/{account_token}/cards")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"user_token\": \"user1234\",\n \"card_product_token\": \"my-card-product1234\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox-api.marqeta.com/v3/credit/accounts/{account_token}/cards")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_token\": \"user1234\",\n \"card_product_token\": \"my-card-product1234\"\n}"
response = http.request(request)
puts response.read_body{
"token": "my_credit_card_token1234",
"user_token": "user1234",
"created_time": "2024-09-03T19:39:53.719Z",
"updated_time": "2024-09-03T19:39:53.719Z",
"account_token": "my_account_token_12"
}{
"code": 123,
"message": "<string>"
}POST////
Create a credit card for an existing credit account.
Note
You can ship cards to an address different from the user address. After creating a card, send a
You can ship cards to an address different from the user address. After creating a card, send a
PUT request to the /cards endpoint with the new address in the fulfillment.shipping object. For more, see Update card.URL path parameters
| Fields | Description |
|---|---|
| account_token string Required | Unique identifier of the credit account for which to create a credit card. Send a GET request to /credit/accounts to retrieve existing credit account tokens.Allowable Values: Existing account token |
Request body
Expected request body to create a credit card for an existing credit account. Refer to Create card for the complete list of fields.Sample request body
JSON
{
"card_product_token": "my-card-product1234",
"user_token": "user1234"
}
Response body
| Fields | Description |
|---|---|
| token string Returned | Unique identifier of the credit card. Allowable Values: 36 char max |
| account_token string Returned | Unique identifier of the associated credit account. Allowable Values: 36 char max Existing account token |
| user_token string Returned | Unique identifier of the credit cardholder. Allowable Values: Existing user token |
| created_time datetime Returned | Date and time when the card was created on Marqeta’s credit platform, in UTC. Allowable Values: Format: yyyy-MM-ddThh:mm:ssZ |
| updated_time datetime Returned | Date and time when the card was last modified on Marqeta’s credit platform, in UTC. Allowable Values: Format: yyyy-MM-ddThh:mm:ssZ |
Sample response body
JSON
{
"token": "my_credit_card_token1234",
"account_token": "my_account_token_12",
"user_token": "user1234",
"created_time": "2024-09-03T19:39:53.719Z",
"updated_time": "2024-09-03T19:39:53.719Z"
}
Authorizations
Path Parameters
Body
application/json
Expected request body to create a credit card for an existing credit account. Refer to <</core-api/cards/#postCards,Create card>> for the complete list of fields.
The body is of type object.
Response
Expected response to a valid request.
Information about a credit card.
Was this page helpful?