---
updatedAt: 2026-04-28T02:11:24.000Z
agentTools:
  projectIndex: https://docs.shipscience.com/llms.txt
---

# Create sub-account

**Partner-only.** Create a child account plus its primary user. The
response includes `password_setup.url`, a one-time link valid for
6 hours that the merchant uses to set their password and log in for
the first time. No email is sent by ShipScience — forward the link
yourself, or let the merchant use the Forgot Password flow after it
expires.

The response also includes `webhook_url`, a unique inbound webhook
URL for this sub-account. Configure your partner integration to POST
events for this sub-account to that URL — one URL maps to exactly
one ShipScience account, so no payload-level routing is required.
Sign each request with HMAC-SHA256 over the raw body using the
signing secret for **this sub-account's webhook credential** —
every sub-account has its own auto-generated signing secret,
available from the ShipScience admin UI. Do not reuse a
master-account secret across sub-accounts.

If you receive `403 Forbidden`, contact support@shipscience.com.


# OpenAPI definition

```json
{
  "openapi": "3.0.1",
  "info": {
    "title": "Shipscience API",
    "version": "v1",
    "description": "ShipScience's REST API for partners and customers.\n\n## Authentication\n\nMost endpoints require a bearer JWT in the `Authorization` header. Tokens\nare issued by the ShipScience login flow and are valid for 4 hours.\nClients are responsible for refreshing tokens before expiry. The\n`/api/v1/tokens` endpoint is an exception — it authenticates with the\n`api-key` header rather than a bearer JWT, since its purpose is to\nissue the JWT itself.\n\n## Partner endpoints\n\nThe **Sub Accounts** section is only available to accounts explicitly\nenabled as partners. If you receive `403 Forbidden`, contact\n**support@shipscience.com** to request access.\n"
  },
  "tags": [
    {
      "name": "Sub Accounts",
      "description": "**Partner-only.** These endpoints allow an authorized partner account to\nprovision and manage child (\"sub\") accounts on ShipScience. Access is\ndisabled by default.\n\nIf you receive `403 Forbidden`, your ShipScience account has not yet been\nenabled for the Partner API. Contact **support@shipscience.com** to\nrequest access.\n"
    }
  ],
  "paths": {
    "/api/v1/sub_accounts": {
      "post": {
        "summary": "Create sub-account",
        "tags": [
          "Sub Accounts"
        ],
        "security": [
          {
            "bearer_auth": []
          }
        ],
        "description": "**Partner-only.** Create a child account plus its primary user. The\nresponse includes `password_setup.url`, a one-time link valid for\n6 hours that the merchant uses to set their password and log in for\nthe first time. No email is sent by ShipScience — forward the link\nyourself, or let the merchant use the Forgot Password flow after it\nexpires.\n\nThe response also includes `webhook_url`, a unique inbound webhook\nURL for this sub-account. Configure your partner integration to POST\nevents for this sub-account to that URL — one URL maps to exactly\none ShipScience account, so no payload-level routing is required.\nSign each request with HMAC-SHA256 over the raw body using the\nsigning secret for **this sub-account's webhook credential** —\nevery sub-account has its own auto-generated signing secret,\navailable from the ShipScience admin UI. Do not reuse a\nmaster-account secret across sub-accounts.\n\nIf you receive `403 Forbidden`, contact support@shipscience.com.\n",
        "parameters": [],
        "responses": {
          "201": {
            "description": "Sub-account created. password_setup.url is valid for 6 hours.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/sub_account_create_response"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON request body. Real HTTP callers receive the standard error envelope (`{ \"error\": { \"message\": \"Malformed JSON request body.\" } }`); the rswag-generated example may be empty because rswag's test path falls through to Rails' default 400 handler in test env. See spec/requests/api/v1/sub_accounts_spec.rb for the real-HTTP behavior."
          },
          "401": {
            "description": "Missing or invalid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/api_error"
                }
              }
            }
          },
          "403": {
            "description": "Account not enabled for the Partner API. Contact support@shipscience.com.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/api_error"
                }
              }
            }
          },
          "409": {
            "description": "External_id or email conflict. For those conflicts, details.existing contains the existing record id. In rare cases (other unique-constraint violations from concurrent races), 409 may be returned with details.code = \"unique_constraint_violation\" and no details.existing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/api_error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/api_error"
                }
              }
            }
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "account": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "example": "Acme Apparel"
                      },
                      "phone": {
                        "type": "string",
                        "nullable": true
                      },
                      "external_id": {
                        "type": "string",
                        "nullable": true,
                        "description": "Your system's unique identifier for this merchant. Optional. If provided, must be unique within your account's children; enables idempotent retries via 409."
                      }
                    },
                    "required": [
                      "name"
                    ]
                  },
                  "primary_user": {
                    "type": "object",
                    "properties": {
                      "email": {
                        "type": "string",
                        "format": "email"
                      },
                      "first_name": {
                        "type": "string"
                      },
                      "last_name": {
                        "type": "string"
                      },
                      "external_id": {
                        "type": "string",
                        "nullable": true
                      }
                    },
                    "required": [
                      "email",
                      "first_name",
                      "last_name"
                    ]
                  }
                },
                "required": [
                  "account",
                  "primary_user"
                ]
              }
            }
          },
          "required": true
        }
      }
    }
  },
  "components": {
    "schemas": {
      "sub_account": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "acc_kD9aQ2pR7vN1xY3zB6cF8e",
            "description": "Public identifier for this sub-account."
          },
          "external_id": {
            "type": "string",
            "nullable": true,
            "example": "merchant_42"
          },
          "name": {
            "type": "string"
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "name",
          "created_at"
        ]
      },
      "sub_account_primary_user": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "usr_p4K2mN8vL1qR9xY3zB6cF7"
          },
          "external_id": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "first_name": {
            "type": "string",
            "nullable": true
          },
          "last_name": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "id",
          "email"
        ]
      },
      "sub_account_password_setup": {
        "type": "object",
        "description": "Password-setup link for the primary user. Valid for **6 hours** from\n`expires_at`. After expiry the merchant uses the standard Forgot\nPassword flow at ShipScience to request a fresh link.\n",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "url",
          "expires_at"
        ]
      },
      "sub_account_create_response": {
        "type": "object",
        "properties": {
          "account": {
            "$ref": "#/components/schemas/sub_account"
          },
          "primary_user": {
            "$ref": "#/components/schemas/sub_account_primary_user"
          },
          "password_setup": {
            "$ref": "#/components/schemas/sub_account_password_setup"
          },
          "webhook_url": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "Per-sub-account inbound webhook URL. Configure your partner integration\nto POST events for this sub-account here. Each request must be\nHMAC-SHA256-signed against the raw body using the signing secret for\n**this sub-account's webhook credential** — every sub-account has its\nown auto-generated signing secret, available from the ShipScience admin\nUI. Do not reuse a master-account secret across sub-accounts. The URL is\nunique per sub-account; one URL maps to exactly one ShipScience account,\nso events posted here are scoped to this sub-account only.\n"
          }
        }
      },
      "api_error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "additionalProperties": true
              }
            },
            "required": [
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      }
    },
    "securitySchemes": {
      "bearer_auth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "servers": [
    {
      "url": "https://app.shipscience.com",
      "variables": {
        "defaultHost": {
          "default": "app.shipscience.com"
        }
      }
    }
  ]
}
```