# SubAccounts

## Get SubAccount

> Retrieve information about a specific sub-account. Only available for agency and developer accounts.

```json
{"openapi":"3.1.0","info":{"title":"DM Champ API","version":"1.0.0"},"servers":[{"url":"https://api.dmchamp.com/v1","description":"Production API Server"}],"security":[{"ApiKeyAuth":[]},{"UserIdAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"query","name":"apiKey","description":"Your DM Champ API key. Obtain from Settings → API Keys."},"UserIdAuth":{"type":"apiKey","in":"query","name":"userId","description":"Your DM Champ User ID. Alternative to apiKey authentication. Cannot be used for agency-only endpoints."}},"parameters":{"ApiKeyParam":{"name":"apiKey","in":"query","description":"API key for authentication. At least one of apiKey or userId is required for protected endpoints.","required":false,"schema":{"type":"string"}}},"schemas":{"SubAccount":{"type":"object","required":["email","first_name","last_name","usage_limits"],"properties":{"email":{"type":"string","description":"Sub-account user's email address","format":"email"},"first_name":{"type":"string","description":"Sub-account user's first name"},"last_name":{"type":"string","description":"Sub-account user's last name"},"role":{"type":"string","description":"Role of the sub-account (always \"Sub Account\")","default":"Sub Account"},"is_agency_sub_account":{"type":"boolean","default":true,"description":"Indicates this is a sub-account"},"business_name":{"type":"string","description":"Business name for the sub-account"},"description":{"type":"string","description":"Business description"},"address_line":{"type":"string","description":"Business address line"},"city":{"type":"string","description":"Business city"},"country":{"type":"string","description":"Business country"},"postal_code":{"type":"string","description":"Business postal code"},"state":{"type":"string","description":"Business state"},"time_zone_id":{"type":"string","description":"Time zone identifier"},"language":{"type":"string","description":"Preferred language"},"usage_limits":{"type":"object","required":["monthly_credits"],"properties":{"monthly_credits":{"type":"integer","description":"Total monthly credits allocated","minimum":1},"monthly_credits_used":{"type":"integer","description":"Number of monthly credits used","default":0},"credits":{"type":"integer","description":"Current credit balance"},"roll_over_to_next_month":{"type":"boolean","description":"Whether unused credits roll over to next month","default":false}}}}}}},"paths":{"/subaccounts":{"get":{"summary":"Get SubAccount","description":"Retrieve information about a specific sub-account. Only available for agency and developer accounts.","tags":["SubAccounts"],"parameters":[{"$ref":"#/components/parameters/ApiKeyParam"},{"name":"email","in":"query","required":true,"schema":{"type":"string","format":"email"},"description":"Email of the sub-account to retrieve"}],"responses":{"200":{"description":"Sub-account found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/SubAccount"}}}}}},"400":{"description":"Invalid request or not an agency account","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"error_code":{"type":"integer","enum":[400]},"error":{"type":"string"}}}}}},"404":{"description":"Sub-account not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"error_code":{"type":"integer","enum":[404]},"error":{"type":"string"}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"error_code":{"type":"integer","enum":[500]},"error":{"type":"string"}}}}}}}}}}}
```

## Create SubAccount

> Create a new sub-account within your agency. Only available for agency and developer accounts.

```json
{"openapi":"3.1.0","info":{"title":"DM Champ API","version":"1.0.0"},"servers":[{"url":"https://api.dmchamp.com/v1","description":"Production API Server"}],"security":[{"ApiKeyAuth":[]},{"UserIdAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"query","name":"apiKey","description":"Your DM Champ API key. Obtain from Settings → API Keys."},"UserIdAuth":{"type":"apiKey","in":"query","name":"userId","description":"Your DM Champ User ID. Alternative to apiKey authentication. Cannot be used for agency-only endpoints."}},"parameters":{"ApiKeyParam":{"name":"apiKey","in":"query","description":"API key for authentication. At least one of apiKey or userId is required for protected endpoints.","required":false,"schema":{"type":"string"}}}},"paths":{"/subaccounts":{"post":{"summary":"Create SubAccount","description":"Create a new sub-account within your agency. Only available for agency and developer accounts.","tags":["SubAccounts"],"parameters":[{"$ref":"#/components/parameters/ApiKeyParam"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email","first_name","last_name","usage_limits"],"properties":{"email":{"type":"string","format":"email","description":"Sub-account user's email address"},"first_name":{"type":"string","description":"Sub-account user's first name"},"last_name":{"type":"string","description":"Sub-account user's last name"},"business_name":{"type":"string","description":"Business name for the sub-account"},"description":{"type":"string","description":"Business description"},"address_line":{"type":"string","description":"Business address line"},"city":{"type":"string","description":"Business city"},"country":{"type":"string","description":"Business country"},"postal_code":{"type":"string","description":"Business postal code"},"state":{"type":"string","description":"Business state"},"time_zone_id":{"type":"string","description":"Time zone identifier"},"language":{"type":"string","description":"Preferred language"},"usage_limits":{"type":"object","required":["monthly_credits"],"properties":{"monthly_credits":{"type":"integer","minimum":1,"description":"Total monthly credits allocated"},"monthly_credits_used":{"type":"integer","default":0,"description":"Number of monthly credits used"},"credits":{"type":"integer","description":"Initial credit balance (defaults to monthly_credits if not specified)"},"roll_over_to_next_month":{"type":"boolean","default":false,"description":"Whether unused credits roll over to next month"}}}}}}}},"responses":{"201":{"description":"Sub-account created successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"email":{"type":"string","format":"email","description":"Sub-account email"},"first_name":{"type":"string","description":"First name"},"last_name":{"type":"string","description":"Last name"},"role":{"type":"string","description":"User role"},"is_agency_sub_account":{"type":"boolean","description":"Indicates this is a sub-account"},"uid":{"type":"string","description":"Firebase UID for the sub-account"},"created_time":{"type":"string","format":"date-time","description":"Account creation timestamp"},"temporary_password":{"type":"string","description":"Temporary password for the sub-account user"},"usage_limits":{"type":"object","properties":{"monthly_credits":{"type":"integer","description":"Total monthly credits allocated"},"monthly_credits_used":{"type":"integer","description":"Number of monthly credits used"},"last_reset_date":{"type":"string","format":"date-time","description":"Date when credits were last reset"},"credits":{"type":"integer","description":"Current credit balance"},"roll_over_to_next_month":{"type":"boolean","description":"Whether unused credits roll over to next month"}}}}}}}}}},"400":{"description":"Invalid input or insufficient credits or not an agency account","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"error_code":{"type":"integer","enum":[400]},"error":{"type":"string","enum":["Missing required fields including usage limits","Monthly credits must be greater than 0","You are not an agency account"]}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"error_code":{"type":"integer","enum":[500]},"error":{"type":"string"}}}}}}}}}}}
```

## Delete SubAccount

> Delete a specific sub-account. Only available for agency and developer accounts.

```json
{"openapi":"3.1.0","info":{"title":"DM Champ API","version":"1.0.0"},"servers":[{"url":"https://api.dmchamp.com/v1","description":"Production API Server"}],"security":[{"ApiKeyAuth":[]},{"UserIdAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"query","name":"apiKey","description":"Your DM Champ API key. Obtain from Settings → API Keys."},"UserIdAuth":{"type":"apiKey","in":"query","name":"userId","description":"Your DM Champ User ID. Alternative to apiKey authentication. Cannot be used for agency-only endpoints."}},"parameters":{"ApiKeyParam":{"name":"apiKey","in":"query","description":"API key for authentication. At least one of apiKey or userId is required for protected endpoints.","required":false,"schema":{"type":"string"}}}},"paths":{"/subaccounts":{"delete":{"summary":"Delete SubAccount","description":"Delete a specific sub-account. Only available for agency and developer accounts.","tags":["SubAccounts"],"parameters":[{"$ref":"#/components/parameters/ApiKeyParam"},{"name":"email","in":"query","required":true,"schema":{"type":"string","format":"email"},"description":"Email of the sub-account to delete"}],"responses":{"200":{"description":"Sub-account deleted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"}}}}}},"400":{"description":"Invalid request or not an agency account","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"error_code":{"type":"integer","enum":[400]},"error":{"type":"string"}}}}}},"404":{"description":"Sub-account not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"error_code":{"type":"integer","enum":[404]},"error":{"type":"string"}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"error_code":{"type":"integer","enum":[500]},"error":{"type":"string"}}}}}}}}}}}
```
