Create a Vehicle Card with Default Values
Learn how to create a vehicle card in the Fleet Management Services API.
Step 1: Fetch your Bearer Token
Use the WEX-provided clientid and clientsecret to request for your bearer token.
CURL
curl --location --request POST 'https://wmd.xc.wexonline.com/oauth-service/uaa/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Accept-Encoding: gzip,deflate,br' \
--data 'grant_type=client_credentials&client_secret=1234&client_id=some-client-id'
Step 2: Find your account
- Fetch the list of accounts.
- Choose the account you want to use for the new card.
CURL
curl --request GET \
'https://wmd.xc.wexonline.com/fleet-service/v3/accounts?page=0&size=25&sort=accountName.keyword' \
--header 'Accept-Encoding: gzip,deflate,br' \
--header 'Authorization: Bearer' \
--header 'Content-Length: 0'
Step 3: Find your card profile
- Fetch the list of card profiles.
- Choose the card profile you want to use for the new card.
CURL
curl --location --request GET 'https://wmd.xc.wexonline.com/fleet-service/v3/accounts/1-A1BAJ2/card-profiles?page=0&size=25' \
--header 'Accept-Encoding: gzip,deflate,br' \
--header 'Authorization: Bearer' \
--header 'Content-Length: 0'
Step 4: Create the card
To successfully create the card, you’ll need the following:
- The Account ID (fetched in Step 2).
- The Card Profile ID (fetched in Step 3).
- To have the physical card created and mailed, set
produce_cardto true. - Vehicle Information: To attach a specific vehicle to this card, provide the vehicle details as shown in the code example.
Let’s explain a few things about this example
- The importance of selecting the right Card Profile: The type of card created is determined by the card profile selected in
card_profile_id. You can see the usage type of the card profile, found at the/accounts/{account-id}/card_profilesendpoint, to determine if the card created is an asset or driver card, whether it’s 1-to-many or 1:1 etc. In this example we happened to create an asset 1-to-many card because of the card profile selected. - When to set a vehicle prompt id: Notice that we did not include a
vehicle_prompt_id. This is because vehicle prompts are not configured on 1-to-many vehicles cards. Instead prompts will be added to the driver entities that can use this vehicle card. - Default Purchase Control Profile: In this example we did not configure a
purchase_control_id, so the default value for the account was configured for the resulting card. If we wanted to select a specific purchase control profile for the card we’d include that field here, with a valid reference from one of the profile options returned from the/accounts/{account-id}/purchase_controlsendpoint. - Note on Shipping: Since no address is provided during card creation, WEX will ship the card to the default card shipping address configured on the account.
- There are a number of other optional configuration parameters you can set and defaults you can choose to override. See the documentation for the
/cardendpoint in the API Reference section.
CURL
curl --location --request POST 'https://wmd.xc.wexonline.com/fleet-service/v3/cards' \
--header 'Accept-Encoding: gzip,deflate,br' \
--header 'userId: 12345' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer' \
--data '{
"account_id": "1-A1BAJ2",
"card_profile_id": "1-KH2P1X",
"produce_card": true,
"vehicle": {
"asset_type": "VEHICLE",
"license_plate": {
"license_plate_number": "abc123",
"license_plate_state": "AB",
"license_plate_country": "CA"
},
"detail": {
"make": "ford",
"model": "f150",
"vin": "18218237393038727278",
"year": "2020",
"start_odometer": 0
},
"company_vehicle_id": "1234",
"vehicle_description": "truck",
"distance_per_unit": "10",
"uom": "Gallon",
"tank_capacity": "35"
}
}'
Was this section helpful?
On this page
- Create a Vehicle Card with Default Values