Create and Update Users
Learn what a Marqeta user is as well as how to create and update it.
We'll cover the following
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
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 |
| string | optional | User's first name Maximum length: 40 characters |
| string | optional | User's last name Maximum length: 40 characters |
| string | optional | User's email address Length: 1–255 characters Note: Email address must be unique among all users. |
| string | optional | User's account password Maximum length: 255 characters Conditions:
|
| string | optional | User's address Maximum length: 255 characters |
| string | optional | Country corresponding to the user's address Maximum length: 40 characters |
| string | optional | User's phone number Format: +00000000000 Maximum length: 255 characters |
| string | optional | Name of the company Maximum length: 255 characters |
| 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. |
| boolean | optional | Set to Note: If the value is set to Default value: |
| 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 |
| 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.
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 |
| 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.
token = '{{USER_TOKEN}}'url = '{{BASE_URL}}users/' + tokendata = 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.