# B2B API Profile Management Guide

## Overview

Profile Management lets you:

- Create a profile for each primary and secondary cardholders associated with an account.
- All calls to the endpoint must have a valid JWT Token.


## Create profiles

Only primary and secondary cardholders can have a profile.
If a profile already exists for a cardholder the new account will be linked to their existing profile.

**API Call Example:**

```shell curl
curl -i -X POST \
  https://api.raipartners.com/b2b/portal/profile \
  -H 'API-Version: 1.0.0' \
  -H 'Authorization: Bearer <YOUR_JWT_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "opa": "1234567890123456",
    "primaryCardholder": {
      "name": {
        "first": "John",
        "last": "Smith",
        "middle": "James"
      },
      "dob": "2000-01-31",
      "ssn": "123456789",
      "cardNumber": "1234567890123456",
      "communications": {
        "mobilePhone": {
          "number": "1234567890",
          "verified": true
        },
        "email": {
          "address": "myemail@email.com",
          "verified": true
        }
      },
      "address": {
        "line1": "1 Main St",
        "line2": "Apt 35",
        "city": "Dallas",
        "state": "TX",
        "zipCode": "75000"
      },
      "income": {
        "amount": 10000,
        "source": "Employment",
        "frequency": "Yearly"
      }
    },
    "secondaryCardholder": {
      "name": {
        "first": "John",
        "last": "Smith",
        "middle": "James"
      },
      "dob": "2000-01-31",
      "ssn": "123456789",
      "cardNumber": "1234567890123456",
      "communications": {
        "mobilePhone": {
          "number": "1234567890",
          "verified": true
        },
        "email": {
          "address": "myemail@email.com",
          "verified": true
        }
      },
      "address": {
        "line1": "1 Main St",
        "line2": "Apt 35",
        "city": "Dallas",
        "state": "TX",
        "zipCode": "75000"
      },
      "income": {
        "amount": 10000,
        "source": "Employment",
        "frequency": "Yearly"
      }
    },
    "authorizedUsers": [
      {
        "name": {
          "first": "John",
          "last": "Smith",
          "middle": "James"
        },
        "dob": "2000-01-31",
        "ssn": "123456789",
        "cardNumber": "1234567890123456",
        "communications": {
          "mobilePhone": {
            "number": "1234567890",
            "verified": true
          },
          "email": {
            "address": "myemail@email.com",
            "verified": true
          }
        },
        "address": {
          "line1": "1 Main St",
          "line2": "Apt 35",
          "city": "Dallas",
          "state": "TX",
          "zipCode": "75000"
        },
        "income": {
          "amount": 10000,
          "source": "Employment",
          "frequency": "Yearly"
        }
      }
    ]
  }'
```

**API Call Response:**
This endpoint returns a 204 status upon success (no content is returned)

```json 400 application/json
{
  "type": "urn:raipartners:api:b2b:errors:validation:invalid-data",
  "title": "Bad Request",
  "status": 400,
  "detail": "One or more fields are invalid."
}
```

```json 401 application/json
{
  "type": "urn:raipartners:api:b2b:errors:authorization:unauthorized",
  "title": "Unauthorized",
  "status": 401,
  "detail": "You are not authorized to perform this action."
}
```

```json 403 application/json
{
  "type": "urn:raipartners:api:b2b:errors:authorization:forbidden",
  "title": "Forbidden",
  "status": 403,
  "detail": "You are forbidden to perform this action."
}
```

```json 404 application/json
{
  "type": "urn:raipartners:api:b2b:errors:not-found",
  "title": "Not Found",
  "status": 404,
  "detail": "Resource not found."
}
```

```json 500 application/json
{
  "type": "urn:raipartners:api:b2b:errors:internal",
  "title": "Internal Server Error",
  "status": 500,
  "detail": "An unexpected error occurred."
}
```

```json 503 application/json
{
  "type": "urn:raipartners:api:b2b:errors:internal",
  "title": "Service unavailable Error",
  "status": 503,
  "detail": "Service is unavailable."
}
```