## Team API examples details summary Create a new user and assign them a virtual vendor card with spend limits. 1. Create user. ```json POST "https://api.brex.com/v2/users" Requires "users" scope REQUEST BODY { "first_name": "Karen", "last_name": "Filippelli", "email": "kfilippelli@dundermifflin.com" } RESPONSE { "id": "cuuser_ckze72soa117f01pkmf1wcpl3", // use this for next call "first_name": "Karen", "last_name": "Filippelli", "email": "kfilippelli@dundermifflin.com", "status": "INVITED" } ``` 1. Check that the user accepted the invite. ```json GET "https://api.brex.com/v2/users/cuuser_ckze72soa117f01pkmf1wcpl3" Requires "users.readonly" or "users" scope RESPONSE { "id": "cuuser_ckze72soa117f01pkmf1wcpl3", "first_name": "Karen", "last_name": "Filippelli", "email": "kfilippelli@dundermifflin.com", "status": "INVITED" // hasn't accepted email invite yet } // They haven't accepted, let's try again later... RESPONSE { "id": "cuuser_ckze72soa117f01pkmf1wcpl3", "first_name": "Karen", "last_name": "Filippelli", "email": "kfilippelli@dundermifflin.com", "status": "ACTIVE" // user has now has accepted and signed up } ``` 1. Create a new `VIRTUAL` vendor card for the user with a `spend_limit`. ```json POST "https://api.brex.com/v2/cards" Requires "cards" scope REQUEST BODY { "owner": { "type": "USER", "user_id": "cuuser_ckze72soa117f01pkmf1wcpl3" }, "card_name": "Party Planning Committee", "card_type": "VIRTUAL", "limit_type": "CARD", "spend_controls": { "spend_limit": { "amount": 100000, "currency": "USD" }, "spend_duration": "MONTHLY", "lock_after_date": "2022-08-24" } } RESPONSE { "id": "ncard_cktdcoaez04db99p29d3ef1z3", // use for next call "owner": { "type": "USER", "user_id": "cuuser_ckze72soa117f01pkmf1wcpl3" }, "status": "ACTIVE", "last_four": "7649", "card_name": "Party Planning Committee", "card_type": "VIRTUAL", "limit_type": "CARD", "spend_controls": { "spend_limit": { "amount": 100000, "currency": "USD" }, "spend_available": { "amount": 100000, "currency": "USD" }, "spend_duration": "MONTHLY", "lock_after_date": "2022-08-24" }, "billing_address": { "line1": "1725 Slough Avenue", "city": "Scranton", "state": "PA", "country": "US", "postal_code": "18505" } } ``` 1. Get the 16-digit credit card number. ```json GET "https://api.brex.com/v2/cards/ncard_cktdcoaez04db99p29d3ef1z3/pan" Requires "cards.readonly" or "cards" scope RESPONSE { "id": "ncard_cktdcoaez04db99p29d3ef1z3", "number": "5556693000197392", "cvv": "713", "expiration_date": { "month": 9, "year": 2024 } } ``` details summary Create a new user and assign them a virtual corporate card. 1. Create user. ```json POST "https://api.brex.com/v2/users" Requires "users" scope REQUEST BODY { "first_name": "Karen", "last_name": "Filippelli", "email": "kfilippelli@dundermifflin.com" } RESPONSE { "id": "cuuser_ckze72soa117f01pkmf1wcpl3", // use this for next call "first_name": "Karen", "last_name": "Filippelli", "email": "kfilippelli@dundermifflin.com", "status": "INVITED" } ``` 1. Check that the user accepted the invite. ```json GET "https://api.brex.com/v2/users/cuuser_ckze72soa117f01pkmf1wcpl3" Requires "users.readonly" or "users" scope RESPONSE { "id": "cuuser_ckze72soa117f01pkmf1wcpl3", "first_name": "Karen", "last_name": "Filippelli", "email": "kfilippelli@dundermifflin.com", "status": "INVITED" // hasn't accepted email invite yet } // They haven't accepted, let's try again later... RESPONSE { "id": "cuuser_ckze72soa117f01pkmf1wcpl3", "first_name": "Karen", "last_name": "Filippelli", "email": "kfilippelli@dundermifflin.com", "status": "ACTIVE" // user has now has accepted and signed up } ``` 1. Create a new `VIRTUAL` card with `limit_type` of `USER`. ```json POST "https://api.brex.com/v2/cards" Requires "cards" scope REQUEST BODY { "owner": { "type": "USER", "user_id": "cuuser_ckze72soa117f01pkmf1wcpl3" }, "card_name": "Karen Virtual Corporate Card", "card_type": "VIRTUAL", "limit_type": "USER" } RESPONSE { "id": "ncard_cktdcoaez04db99p29d3ef1z3", // use for next call "owner": { "type": "USER", "user_id": "cuuser_ckze72soa117f01pkmf1wcpl3" }, "status": "ACTIVE", "last_four": "7649", "card_name": "Karen Virtual Corporate Card", "card_type": "VIRTUAL", "limit_type": "USER", "billing_address": { "line1": "1725 Slough Avenue", "city": "Scranton", "state": "PA", "country": "US", "postal_code": "18505" } } ``` 1. Get the 16-digit credit card number. ```json GET "https://api.brex.com/v2/cards/ncard_cktdcoaez04db99p29d3ef1z3/pan" Requires "cards.readonly" or "cards" scope RESPONSE { "id": "ncard_cktdcoaez04db99p29d3ef1z3", "number": "5556693000197392", "cvv": "713", "expiration_date": { "month": 9, "year": 2024 } } ```