Docs
Introduction

Documentation

Learn how to integrate ConnectX into your application.

Shipping API Overview

Learn how to manage shipping addresses in ConnectX

The Shipping API allows you to manage shipping addresses for users in ConnectX. You can create, update, and delete shipping addresses, as well as retrieve addresses for specific users.

All API requests require authentication using an API key. Include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

All API endpoints are relative to the base URL:

https://connectx-backend-4o0i.onrender.com/api

Shipping Addresses

  • GET /shipping/my_address/ - List current user's addresses
  • POST /shipping/ - Create a new address
  • PATCH /shipping/{id}/ - Update an address
  • DELETE /shipping/{id}/ - Delete an address

User Permissions

  • Regular users can only manage their own shipping addresses
  • Users can create, update, and delete their own shipping addresses

Default Address

  • Users can set one address as their default shipping address
  • Setting a new default address will automatically unset the previous default
  • The default address is used for new orders unless specified otherwise

Get a list of shipping addresses for the current authenticated user.

Command

curl -X GET 'https://connectx-backend-4o0i.onrender.com/api/shipping/my_address/' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json'

Response

[
  {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "user": "123e4567-e89b-12d3-a456-426614174001",
    "address_line1": "123 Main St",
    "address_line2": "Apt 4B",
    "city": "New York",
    "state": "NY",
    "postal_code": "10001",
    "country": "USA",
    "is_default": true,
    "created_at": "2024-01-01T00:00:00Z",
    "updated_at": "2024-01-01T00:00:00Z"
  },
  {
    "id": "123e4567-e89b-12d3-a456-426614174002",
    "user": "123e4567-e89b-12d3-a456-426614174001",
    "address_line1": "456 Oak Ave",
    "address_line2": null,
    "city": "Los Angeles",
    "state": "CA",
    "postal_code": "90001",
    "country": "USA",
    "is_default": false,
    "created_at": "2024-01-02T00:00:00Z",
    "updated_at": "2024-01-02T00:00:00Z"
  }
]

Create a new shipping address for the current user.

Command

curl -X POST 'https://connectx-backend-4o0i.onrender.com/api/shipping/' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "address_line1": "789 Pine St",
    "address_line2": "Suite 100",
    "city": "Chicago",
    "state": "IL",
    "postal_code": "60601",
    "country": "USA",
    "is_default": false
  }'

Response

{
  "id": "123e4567-e89b-12d3-a456-426614174003",
  "user": "123e4567-e89b-12d3-a456-426614174001",
  "address_line1": "789 Pine St",
  "address_line2": "Suite 100",
  "city": "Chicago",
  "state": "IL",
  "postal_code": "60601",
  "country": "USA",
  "is_default": false,
  "created_at": "2024-01-03T00:00:00Z",
  "updated_at": "2024-01-03T00:00:00Z"
}

Update an existing shipping address.

Command

curl -X PATCH 'https://connectx-backend-4o0i.onrender.com/api/shipping/123e4567-e89b-12d3-a456-426614174000/' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "address_line1": "Updated Address",
    "city": "Updated City",
    "is_default": true
  }'

Response

{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "user": "123e4567-e89b-12d3-a456-426614174001",
  "address_line1": "Updated Address",
  "address_line2": "Apt 4B",
  "city": "Updated City",
  "state": "NY",
  "postal_code": "10001",
  "country": "USA",
  "is_default": true,
  "created_at": "2024-01-01T00:00:00Z",
  "updated_at": "2024-01-04T00:00:00Z"
}

Delete a shipping address.

Command

curl -X DELETE 'https://connectx-backend-4o0i.onrender.com/api/shipping/123e4567-e89b-12d3-a456-426614174000/' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN'

Response

{
  "message": "Shipping address deleted successfully"
}