Create and Update Users

Learn what a Marqeta user is as well as how to create and update it.

A Marqeta user, also known as a cardholder, is a person who owns a Marqeta card. A Marqeta user can use funds from an account with a physical or virtual Marqeta card. Each Marqeta user is also an account holder since every user has a general purpose account (GPA) that they can use to transfer funds.

Moreover, we have a parent-child relationship among Marqeta users, where one user or businessA business is an account holder that can be a parent of a Marqeta user. While a business itself does not hold any cards, its child users do. can be the parent of another user. In terms of card usage, this relationship provides a certain amount of control to the parent account over the child account. A parent user can monitor or restrict the user’s card usage. This relationship also allows us to share the parent account by the child user, who can then access the funds from the parent account.

This parent-child relationship can extend to multiple levels. This means that a general user account can be a child of a business and the parent of another user. In a case like that, the general user should not be able to use balances of their parent account. However, the general user’s child account can be configured to use the balances of their parent account (the general user).

In this lesson, we’ll learn how to create and update a Marqeta user.

Create a Marqeta user

We can create a Marqeta user by making a POST request to the {BASE_URL}/users endpoint. We can provide the user’s basic information in the body of the request. If we want to create a child user, we must provide a value for the parent_token. Additionally, we can allow the child user to share an account with their parent by setting the uses_parent_account field value to True.

Note: If a child user shares an account with the parent user, they can’t spend funds if the parent is inactive. However, they can still activate cards.

Request Parameters

Parameter

Type

Category

Description

first_name

string

optional

User's first name

Maximum length: 40 characters

last_name

string

optional

User's last name

Maximum length: 40 characters

email

string

optional

User's email address

Length: 1–255 characters

Note: Email address must be unique among all users.

password

string

optional

User's account password

Maximum length: 255 characters

Conditions:

  •  Must contain at least one numeric digit
  •  Must contain at least one lowercase letter
  •  Must contain at least one uppercase letter
  •  Must contain at least one of the following symbols: @ # $ % ! ^ & * ( ) \ _ + ~ ` - = [ ] { } , ; : ' " , . / < > ?

address1

string

optional

User's address

Maximum length: 255 characters

country

string

optional

Country corresponding to the user's address

Maximum length: 40 characters

phone

string

optional

User's phone number

Format: +00000000000

Maximum length: 255 characters

company

string

optional

Name of the company

Maximum length: 255 characters

token

string

optional

Unique token of the user

Length: 1–36 characters

Note: If not specified, the system generates one automatically. This value can't be updated once set.

uses_parent_account

boolean

optional

Set to True if the child account shares balances with the parent, "False" otherwise this value is False.

Note: If the value is set to True, the parent_token must also have a value be set. This value can't be updated once set.

Default value: False

parent_token

string

optional

Token of a user or business that is be set as the parent of the current user

Note: This parameter is required if uses_parent_account = True.

active

boolean

optional

Status of the user

Note: The above list of input parameters is not exhaustive. Please refer to this course’s appendix for the remaining parameters.

Lines 4-5: We add values for the two optional parameters, first_name and last_name.

Note: You may also enter values for the other optional parameters given in the table above.

Click the “Run” button in the code widget below to see the output.

Press + to interact
url = '{{BASE_URL}}users'
data = json.dumps({
"first_name": "",
"last_name": ""
})
response = requests.post(url, headers=headers, data=data)
printResponse(response)

When the code is executed successfully, the output displays the complete user object with all of the requested data fields. It extracts, the token field and saves it as USER_TOKEN. We’ll use this key to update the user and perform other operations later on in this course.

In case of failure, an appropriate error message is displayed.

Update a Marqeta user

We can update a Marqeta user by making a PUT request to the {BASE_URL}/users/{token} endpoint. The path parameter ({token}) refers to the token of the user we want to update. We also need to specify the fields that we want to update in the body of the request.

Path Parameter

Parameter

Type

Category

Description

token

string

required

Token of the user we want to update

Note: Refer to the input parameters table for creating a Marqeta user to find the fields we can update. We can update all fields except for those restricted in that table.

In the code below, we change the last_name of a given user.

Note: You may opt to change any of the attribute(s) given in the table we used when we created a user.

Line 1: For token, we’ve used the USER_TOKEN value that we saved in the previous example. However, you may change it in case you want to update any other user.

Line 6: Enter the value for the last_name.

Click the “Run” button in the code widget below to see the output.

Press + to interact
token = '{{USER_TOKEN}}'
url = '{{BASE_URL}}users/' + token
data = json.dumps({
"last_name": ""
})
response = requests.put(url, headers=headers, data=data)
printResponse(response)

When the code is successfully executed, the output displays the complete user object that corresponds to the given token with all of the requested data fields. This includes the fields we just updated.

In case of failure, an appropriate error message is displayed.