# CarrierType

The `CarrierType` object provides an interface for determining the valid fields of a `CarrierAccount`.
The list of `CarrierType` objects only changes when a new carrier is added to EasyPost.

The `CarrierType` objects consist of their top level attributes as well as a `Fields` object that contains `credentials` and sometimes `test_credentials` sub-objects, which themselves are collections of attributes for `CarrierAccounts` creation, as well as metadata about presentation and the naming of said attributes.

There are a couple special case `CarrierAccounts`, with structures differing somewhat from the norm.
For instance, instead of credentials for a "UspsAccount", it has only `auto_link: true`, which indicates that it is an account that can be added or removed without any carrier-specific fields.

---

## CarrierType object

| Property | Type | Description |
|----------|------|-------------|
| object | string | "CarrierType" |
| type | string | Specifies the CarrierAccount type |
| readable | string | The human-readable name of the CarrierType |
| logo | string |  |
| fields | Fields object | Contains at least one of the following keys: auto_link credentials test_credentials custom_workflow |

Example Object:

```json
[
  {
    "object": "CarrierType",
    "type": "UpsAccount",
    "readable": "UPS",
    "logo": null,
    "fields": {
      "credentials": {
        "access_license_number": {
          "visibility": "invisible",
          "label": "UPS Access License Number"
        },
        "account_number": {
          "visibility": "readonly",
          "label": "UPS Account Number"
        },
        "user_id": {
          "visibility": "invisible",
          "label": "UPS.com User ID"
        },
        "password": {
          "visibility": "invisible",
          "label": "UPS.com Password"
        },
        "oauth_status": {
          "visibility": "readonly",
          "label": "OAuth Authorization Status"
        },
        "partner_oauth_url": {
          "visibility": "readonly",
          "label": "OAuth Portal URL"
        }
      }
    }
  },
  {
    "object": "CarrierType",
    "type": "UpsMailInnovationsAccount",
    "readable": "UPS Mail Innovations",
    "logo": null,
    "fields": {
      "credentials": {
        "account_number": {
          "visibility": "visible",
          "label": "UPS Shipper Number"
        },
        "user_id": {
          "visibility": "visible",
          "label": "UPS.com User ID"
        },
        "password": {
          "visibility": "password",
          "label": "UPS.com Password"
        },
        "customer_id": {
          "visibility": "visible",
          "label": "UPS customer id (optional)"
        },
        "customer_guid": {
          "visibility": "visible",
          "label": "UPS customer GUID (optional)"
        },
        "oauth_status": {
          "visibility": "readonly",
          "label": "OAuth Authorization Status"
        },
        "partner_oauth_url": {
          "visibility": "readonly",
          "label": "OAuth Portal URL"
        }
      }
    }
  },
  {
    "object": "CarrierType",
    "type": "AccurateAccount",
    "readable": "Accurate",
    "logo": null,
    "fields": {
      "credentials": {
        "username": {
          "visibility": "visible",
          "label": "Accurate username"
        },
        "password": {
          "visibility": "password",
          "label": "Accurate password"
        }
      },
      "test_credentials": {
        "username": {
          "visibility": "visible",
          "label": "Accurate test username"
        },
        "password": {
          "visibility": "password",
          "label": "Accurate test password"
        }
      }
    }
  }
]
```

---

## Fields object

| Property | Type | Description |
|----------|------|-------------|
| auto_link | boolean | If this key is present with the value of true, no other attributes are needed for CarrierAccount creation . |
| custom_workflow | boolean | If this key is present with the value of true, CarrierAccount creation of this type requires extra work not handled by the CarrierAccount standard API. |
| credentials | Credentials object | If this object is present, required attribute names and their metadata are presented inside. |
| test_credentials | Credentials object | If this object is present, it contains attribute names and metadata just as the credentials object. It is not required for CarrierAccount creation if you do not plan on using the CarrierAccount for test mode. |

Example Object:

```json
[
  {
    "object": "CarrierType",
    "type": "UpsAccount",
    "readable": "UPS",
    "logo": null,
    "fields": {
      "credentials": {
        "access_license_number": {
          "visibility": "invisible",
          "label": "UPS Access License Number"
        },
        "account_number": {
          "visibility": "readonly",
          "label": "UPS Account Number"
        },
        "user_id": {
          "visibility": "invisible",
          "label": "UPS.com User ID"
        },
        "password": {
          "visibility": "invisible",
          "label": "UPS.com Password"
        },
        "oauth_status": {
          "visibility": "readonly",
          "label": "OAuth Authorization Status"
        },
        "partner_oauth_url": {
          "visibility": "readonly",
          "label": "OAuth Portal URL"
        }
      }
    }
  },
  {
    "object": "CarrierType",
    "type": "UpsMailInnovationsAccount",
    "readable": "UPS Mail Innovations",
    "logo": null,
    "fields": {
      "credentials": {
        "account_number": {
          "visibility": "visible",
          "label": "UPS Shipper Number"
        },
        "user_id": {
          "visibility": "visible",
          "label": "UPS.com User ID"
        },
        "password": {
          "visibility": "password",
          "label": "UPS.com Password"
        },
        "customer_id": {
          "visibility": "visible",
          "label": "UPS customer id (optional)"
        },
        "customer_guid": {
          "visibility": "visible",
          "label": "UPS customer GUID (optional)"
        },
        "oauth_status": {
          "visibility": "readonly",
          "label": "OAuth Authorization Status"
        },
        "partner_oauth_url": {
          "visibility": "readonly",
          "label": "OAuth Portal URL"
        }
      }
    }
  },
  {
    "object": "CarrierType",
    "type": "AccurateAccount",
    "readable": "Accurate",
    "logo": null,
    "fields": {
      "credentials": {
        "username": {
          "visibility": "visible",
          "label": "Accurate username"
        },
        "password": {
          "visibility": "password",
          "label": "Accurate password"
        }
      },
      "test_credentials": {
        "username": {
          "visibility": "visible",
          "label": "Accurate test username"
        },
        "password": {
          "visibility": "password",
          "label": "Accurate test password"
        }
      }
    }
  }
]
```

---

## Credentials object

| Property | Type | Description |
|----------|------|-------------|
| name | string | The key for each attribute sub-object within credentials is the name of the attribute for submission on CarrierAccounts |
| visibility | string | There are five possible values, which encode the security need and storage type for each attribute: visible checkbox fake password masked |
| label | string | Most attributes have generic names, so for clarity, a "label" value is provided for clearer representation when rendering forms. |

Example Object:

```json
[
  {
    "object": "CarrierType",
    "type": "UpsAccount",
    "readable": "UPS",
    "logo": null,
    "fields": {
      "credentials": {
        "access_license_number": {
          "visibility": "invisible",
          "label": "UPS Access License Number"
        },
        "account_number": {
          "visibility": "readonly",
          "label": "UPS Account Number"
        },
        "user_id": {
          "visibility": "invisible",
          "label": "UPS.com User ID"
        },
        "password": {
          "visibility": "invisible",
          "label": "UPS.com Password"
        },
        "oauth_status": {
          "visibility": "readonly",
          "label": "OAuth Authorization Status"
        },
        "partner_oauth_url": {
          "visibility": "readonly",
          "label": "OAuth Portal URL"
        }
      }
    }
  },
  {
    "object": "CarrierType",
    "type": "UpsMailInnovationsAccount",
    "readable": "UPS Mail Innovations",
    "logo": null,
    "fields": {
      "credentials": {
        "account_number": {
          "visibility": "visible",
          "label": "UPS Shipper Number"
        },
        "user_id": {
          "visibility": "visible",
          "label": "UPS.com User ID"
        },
        "password": {
          "visibility": "password",
          "label": "UPS.com Password"
        },
        "customer_id": {
          "visibility": "visible",
          "label": "UPS customer id (optional)"
        },
        "customer_guid": {
          "visibility": "visible",
          "label": "UPS customer GUID (optional)"
        },
        "oauth_status": {
          "visibility": "readonly",
          "label": "OAuth Authorization Status"
        },
        "partner_oauth_url": {
          "visibility": "readonly",
          "label": "OAuth Portal URL"
        }
      }
    }
  },
  {
    "object": "CarrierType",
    "type": "AccurateAccount",
    "readable": "Accurate",
    "logo": null,
    "fields": {
      "credentials": {
        "username": {
          "visibility": "visible",
          "label": "Accurate username"
        },
        "password": {
          "visibility": "password",
          "label": "Accurate password"
        }
      },
      "test_credentials": {
        "username": {
          "visibility": "visible",
          "label": "Accurate test username"
        },
        "password": {
          "visibility": "password",
          "label": "Accurate test password"
        }
      }
    }
  }
]
```

---

**Production Only**
## Retrieve available Carrier Types

### Example: GET /carrier_types

#### cURL

```shell
curl -X GET https://api.easypost.com/v2/carrier_types \
  -u "EASYPOST_API_KEY":
```

#### Go

```go
package example

import (
	"fmt"

	"github.com/EasyPost/easypost-go/v5"
)

func list() {
	client := easypost.New("EASYPOST_API_KEY")

	carrierTypes, _ := client.GetCarrierTypes()

	fmt.Println(carrierTypes)
}
```

#### Java

```java
package carrier_types;

import com.easypost.exception.EasyPostException;
import com.easypost.model.CarrierType;
import com.easypost.service.EasyPostClient;

import java.util.List;

public class All {
    public static void main(String[] args) throws EasyPostException {
        EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

        List<CarrierType> carrierTypes = client.carrierType.all();

        System.out.println(carrierTypes);
    }
}
```

#### C#

```csharp
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using EasyPost;
using Newtonsoft.Json;

namespace EasyPostExamples
{
    public class Examples
    {
        public static async Task Main()
        {
            var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

            List<EasyPost.Models.API.CarrierType> carrierTypes = await client.CarrierType.All();

            Console.WriteLine(JsonConvert.SerializeObject(carrierTypes, Formatting.Indented));
        }
    }
}
```

#### Node.js

```javascript
const EasyPostClient = require('@easypost/api');

const client = new EasyPostClient('EASYPOST_API_KEY');

(async () => {
  const carrierTypes = await client.CarrierType.all();

  console.log(carrierTypes);
})();
```

#### PHP

```php
<?php

$client = new \EasyPost\EasyPostClient('EASYPOST_API_KEY');

$carrierTypes = $client->carrierAccount->types();

echo $carrierTypes;
```

#### Python

```python
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

carrier_types = client.carrier_account.types()

print(carrier_types)
```

#### Ruby

```ruby
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

carrier_types = client.carrier_account.types

puts carrier_types
```

The `CarrierType` list is an unpaginated list of all carrier types available to the account of the given API key.