> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.mycargoextra.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mycargoextra.com/_mcp/server.

# Create User Address

POST http://localhost:9000/api/v1/address
Content-Type: application/json

Creates an address for the authenticated customer.

Required body fields: `email`, `address1`, `state`, `country`. Optional: `company`, `phone`, `address2`, `city`, `zipCode`, `default`.

Response fields: the created address document.

Possible errors:
- 400: Invalid address Id - path id is not a valid Mongo ObjectId.
- 404: Address not found or not authorized - address does not exist or belongs to another customer.
- 409: Address already exists - duplicate address detected.
- 400: Default address cannot be deleted - unset/change default first.
- 400: Missing One or More Required Parameters - required body/query fields were not supplied.
- 401: Unauthorized - token is missing, expired, invalid, or the account/token pair was not found.
- 403: Access denied - gateway traffic guard/rate policy blocked the request.
- 429: Too many requests - gateway rate limit exceeded.
- 500: Unexpected Error - unhandled gateway or downstream service failure.

Reference: https://docs.mycargoextra.com/cargo-extra-gateway-api-copy/address/create-user-address

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: collection
  version: 1.0.0
paths:
  /api/v1/address:
    post:
      operationId: create-user-address
      summary: Create User Address
      description: >-
        Creates an address for the authenticated customer.


        Required body fields: `email`, `address1`, `state`, `country`. Optional:
        `company`, `phone`, `address2`, `city`, `zipCode`, `default`.


        Response fields: the created address document.


        Possible errors:

        - 400: Invalid address Id - path id is not a valid Mongo ObjectId.

        - 404: Address not found or not authorized - address does not exist or
        belongs to another customer.

        - 409: Address already exists - duplicate address detected.

        - 400: Default address cannot be deleted - unset/change default first.

        - 400: Missing One or More Required Parameters - required body/query
        fields were not supplied.

        - 401: Unauthorized - token is missing, expired, invalid, or the
        account/token pair was not found.

        - 403: Access denied - gateway traffic guard/rate policy blocked the
        request.

        - 429: Too many requests - gateway rate limit exceeded.

        - 500: Unexpected Error - unhandled gateway or downstream service
        failure.
      tags:
        - subpackage_address
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/address_Create User Address_Response_201'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostApiV1AddressRequestBadRequestError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostApiV1AddressRequestUnauthorizedError'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostApiV1AddressRequestForbiddenError'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostApiV1AddressRequestNotFoundError'
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostApiV1AddressRequestConflictError'
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PostApiV1AddressRequestTooManyRequestsError
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PostApiV1AddressRequestInternalServerError
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                city:
                  type: string
                email:
                  type: string
                  format: email
                phone:
                  type: string
                state:
                  type: string
                company:
                  type: string
                country:
                  type: string
                default:
                  type: boolean
                zipCode:
                  type: string
                address1:
                  type: string
                address2:
                  type: string
              required:
                - city
                - email
                - phone
                - state
                - company
                - country
                - default
                - zipCode
                - address1
                - address2
servers:
  - url: http://localhost:9000
    description: http://localhost:9000
components:
  schemas:
    address_Create User Address_Response_201:
      type: object
      properties:
        key_0:
          type: integer
        key_1:
          type: string
        key_2:
          type: number
          format: double
        key_3:
          type: string
        key_4:
          type: boolean
      required:
        - key_0
        - key_1
        - key_2
        - key_3
        - key_4
      title: address_Create User Address_Response_201
    PostApiV1AddressRequestBadRequestError:
      type: object
      properties:
        message:
          type: string
      required:
        - message
      title: PostApiV1AddressRequestBadRequestError
    PostApiV1AddressRequestUnauthorizedError:
      type: object
      properties:
        message:
          type: string
      required:
        - message
      title: PostApiV1AddressRequestUnauthorizedError
    PostApiV1AddressRequestForbiddenError:
      type: object
      properties:
        message:
          type: string
      required:
        - message
      title: PostApiV1AddressRequestForbiddenError
    PostApiV1AddressRequestNotFoundError:
      type: object
      properties:
        message:
          type: string
      required:
        - message
      title: PostApiV1AddressRequestNotFoundError
    PostApiV1AddressRequestConflictError:
      type: object
      properties:
        message:
          type: string
      required:
        - message
      title: PostApiV1AddressRequestConflictError
    PostApiV1AddressRequestTooManyRequestsError:
      type: object
      properties:
        message:
          type: string
      required:
        - message
      title: PostApiV1AddressRequestTooManyRequestsError
    PostApiV1AddressRequestInternalServerError:
      type: object
      properties:
        message:
          type: string
      required:
        - message
      title: PostApiV1AddressRequestInternalServerError

```

## Examples



**Request**

```json
{
  "city": "Lagos",
  "email": "receiver@example.com",
  "phone": "+2348012345678",
  "state": "Lagos",
  "company": "CargoExtra Receiver Ltd",
  "country": "Nigeria",
  "default": false,
  "zipCode": "100001",
  "address1": "12 Example Street",
  "address2": "Suite 4"
}
```

**Response**

```json
{
  "key_0": 7724,
  "key_1": "string",
  "key_2": 4012.6776549813535,
  "key_3": "string",
  "key_4": false
}
```

**SDK Code**

```python address_Create User Address_example
import requests

url = "http://localhost:9000/api/v1/address"

payload = {
    "city": "Lagos",
    "email": "receiver@example.com",
    "phone": "+2348012345678",
    "state": "Lagos",
    "company": "CargoExtra Receiver Ltd",
    "country": "Nigeria",
    "default": False,
    "zipCode": "100001",
    "address1": "12 Example Street",
    "address2": "Suite 4"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript address_Create User Address_example
const url = 'http://localhost:9000/api/v1/address';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"city":"Lagos","email":"receiver@example.com","phone":"+2348012345678","state":"Lagos","company":"CargoExtra Receiver Ltd","country":"Nigeria","default":false,"zipCode":"100001","address1":"12 Example Street","address2":"Suite 4"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go address_Create User Address_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "http://localhost:9000/api/v1/address"

	payload := strings.NewReader("{\n  \"city\": \"Lagos\",\n  \"email\": \"receiver@example.com\",\n  \"phone\": \"+2348012345678\",\n  \"state\": \"Lagos\",\n  \"company\": \"CargoExtra Receiver Ltd\",\n  \"country\": \"Nigeria\",\n  \"default\": false,\n  \"zipCode\": \"100001\",\n  \"address1\": \"12 Example Street\",\n  \"address2\": \"Suite 4\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby address_Create User Address_example
require 'uri'
require 'net/http'

url = URI("http://localhost:9000/api/v1/address")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"city\": \"Lagos\",\n  \"email\": \"receiver@example.com\",\n  \"phone\": \"+2348012345678\",\n  \"state\": \"Lagos\",\n  \"company\": \"CargoExtra Receiver Ltd\",\n  \"country\": \"Nigeria\",\n  \"default\": false,\n  \"zipCode\": \"100001\",\n  \"address1\": \"12 Example Street\",\n  \"address2\": \"Suite 4\"\n}"

response = http.request(request)
puts response.read_body
```

```java address_Create User Address_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("http://localhost:9000/api/v1/address")
  .header("Content-Type", "application/json")
  .body("{\n  \"city\": \"Lagos\",\n  \"email\": \"receiver@example.com\",\n  \"phone\": \"+2348012345678\",\n  \"state\": \"Lagos\",\n  \"company\": \"CargoExtra Receiver Ltd\",\n  \"country\": \"Nigeria\",\n  \"default\": false,\n  \"zipCode\": \"100001\",\n  \"address1\": \"12 Example Street\",\n  \"address2\": \"Suite 4\"\n}")
  .asString();
```

```php address_Create User Address_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:9000/api/v1/address', [
  'body' => '{
  "city": "Lagos",
  "email": "receiver@example.com",
  "phone": "+2348012345678",
  "state": "Lagos",
  "company": "CargoExtra Receiver Ltd",
  "country": "Nigeria",
  "default": false,
  "zipCode": "100001",
  "address1": "12 Example Street",
  "address2": "Suite 4"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp address_Create User Address_example
using RestSharp;

var client = new RestClient("http://localhost:9000/api/v1/address");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"city\": \"Lagos\",\n  \"email\": \"receiver@example.com\",\n  \"phone\": \"+2348012345678\",\n  \"state\": \"Lagos\",\n  \"company\": \"CargoExtra Receiver Ltd\",\n  \"country\": \"Nigeria\",\n  \"default\": false,\n  \"zipCode\": \"100001\",\n  \"address1\": \"12 Example Street\",\n  \"address2\": \"Suite 4\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift address_Create User Address_example
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "city": "Lagos",
  "email": "receiver@example.com",
  "phone": "+2348012345678",
  "state": "Lagos",
  "company": "CargoExtra Receiver Ltd",
  "country": "Nigeria",
  "default": false,
  "zipCode": "100001",
  "address1": "12 Example Street",
  "address2": "Suite 4"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:9000/api/v1/address")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```