{"components":{"schemas":{"Account":{"properties":{"email":{"example":"acme@example.com","nullable":true,"type":"string"},"externalAccountId":{"description":"Optionally provide the ID for this account in your CRM or database","example":"b6726f23-1440-4206-962f-8c429f61714c","nullable":true,"type":"string"},"id":{"description":"The ID for this account in Structurely","example":"650ba6ced07cb5552a2467b0","format":"ObjectId","type":"string"},"integrations":{"allOf":[{"$ref":"#/components/schemas/AccountIntegrations"}],"description":"Bonzo, Sierra, and Agent Legend integration status.","readOnly":true},"name":{"example":"Acme Widget","type":"string"},"phone":{"description":"E.164 formatted number","example":"+13035555555","nullable":true,"type":"string"}},"type":"object"},"AccountHasNoBrokerError":{"properties":{"message":{"description":"A message describing why access-token provisioning failed.","example":"Account has no broker","type":"string"},"statusCode":{"example":409,"type":"number"}},"required":["message","statusCode"],"type":"object"},"AccountInfo":{"properties":{"accountId":{"type":"string"},"accountName":{"type":"string"}},"required":["accountId","accountName"],"type":"object"},"AccountIntegrationStatus":{"properties":{"error":{"description":"Integration error message, if any.","example":null,"nullable":true,"readOnly":true,"type":"string"},"status":{"description":"Integration configuration status.","enum":["NotConfigured","Healthy","NotHealthy"],"example":"NotConfigured","readOnly":true,"type":"string"}},"required":["error","status"],"type":"object"},"AccountIntegrations":{"properties":{"agentLegend":{"allOf":[{"$ref":"#/components/schemas/AccountIntegrationStatus"}],"description":"Agent Legend integration status.","readOnly":true},"bonzo":{"allOf":[{"$ref":"#/components/schemas/AccountIntegrationStatus"}],"description":"Bonzo integration status.","readOnly":true},"sierra":{"allOf":[{"$ref":"#/components/schemas/AccountIntegrationStatus"}],"description":"Sierra integration status.","readOnly":true}},"required":["agentLegend","bonzo","sierra"],"type":"object"},"AccountListResponse":{"properties":{"cursor":{"description":"Pagination cursor for the next page, binding the account ID and any normalized name filter.","nullable":true,"type":"string"},"items":{"description":"Active brokerage accounts for the authenticated reseller.","items":{"$ref":"#/components/schemas/Account"},"type":"array"},"next":{"description":"Fully-qualified next-page URL containing only the cursor.","nullable":true,"type":"string"}},"required":["items"],"type":"object"},"AgentLegendIntegration":{"properties":{"accountId":{"description":"Agent Legend's unique account ID","example":"agent-legend-account-12345","type":"string"},"apiEndpoint":{"description":"Optional HTTPS Agent Legend API base URL override.","example":"https://tenant.agentlegend.example/api","format":"uri","nullable":true,"type":"string"},"authToken":{"description":"An Agent Legend auth token allowing Structurely to access resources for this account","example":"XXXXXXXXXXXXXXXXXXX","type":"string"}},"required":["accountId","authToken"],"type":"object"},"BonzoIntegration":{"properties":{"accountId":{"description":"Bonzo's Unique ID for the account","example":"b6726f23-1440-4206-962f-8c429f61714c","type":"string"},"apiToken":{"description":"A Bonzo access token allowing Structurely to access resources for this account","example":"XXXXXXXXXXXXXXXXXXX","type":"string"}},"required":["accountId","apiToken"],"type":"object"},"CreateAccessToken":{"additionalProperties":false,"properties":{"scopes":{"default":["read:conversations","write:conversations","read:users","write:users","read:account","write:account"],"description":"Direct API scopes for the new token. When omitted, scopes default to exactly: read:conversations, write:conversations, read:users, write:users, read:account, write:account. Duplicate scopes are rejected.","example":["read:conversations","write:conversations","read:users","write:users","read:account","write:account"],"items":{"enum":["read:conversations","write:conversations","read:users","write:users","read:account","write:account"],"type":"string"},"minItems":1,"type":"array","uniqueItems":true}},"type":"object"},"CreateAccessTokenResponse":{"properties":{"accessToken":{"description":"A long-lived Direct API access token.","example":"XXXXXXXXXXXXXXXXXXX","type":"string"},"scopes":{"description":"Effective Direct API scopes for the new token.","items":{"enum":["read:conversations","write:conversations","read:users","write:users","read:account","write:account"],"type":"string"},"type":"array"}},"required":["accessToken","scopes"],"type":"object"},"CreateAccount":{"properties":{"accountName":{"example":"Acme Brokerage","type":"string"},"email":{"example":"acme@example.com","type":"string"},"externalAccountId":{"description":"Optionally provide the ID for this account in your CRM or database","example":"b6726f23-1440-4206-962f-8c429f61714c","nullable":true,"type":"string"},"integrations":{"anyOf":[{"$ref":"#/components/schemas/IntegrationMetadata"},{"nullable":true,"type":"object"}],"description":"Optional integration-specific metadata.","example":null},"isFauxUser":{"default":false,"description":"Create the primary broker as an active faux user.","example":false,"type":"boolean"},"name":{"example":"Jane Broker","type":"string"},"phone":{"description":"E.164 formatted number","example":"+13035555555","type":"string"}},"required":["accountName","email","name","phone"],"type":"object"},"CreateAccountResponse":{"properties":{"accessToken":{"description":"A long lived API Access token, used to interact with this account's resources (Enroll Leads, Call Leads, ETC)","example":"XXXXXXXXXXXXXXXXXXX","type":"string"},"email":{"example":"acme@example.com","nullable":true,"type":"string"},"externalAccountId":{"description":"Optionally provide the ID for this account in your CRM or database","example":"b6726f23-1440-4206-962f-8c429f61714c","nullable":true,"type":"string"},"id":{"description":"The ID for this account in Structurely","example":"650ba6ced07cb5552a2467b0","format":"ObjectId","type":"string"},"integrations":{"allOf":[{"$ref":"#/components/schemas/AccountIntegrations"}],"description":"Bonzo, Sierra, and Agent Legend integration status.","readOnly":true},"isFauxUser":{"description":"Whether the created primary broker is a faux user.","type":"boolean"},"name":{"example":"Acme Widget","type":"string"},"phone":{"description":"E.164 formatted number","example":"+13035555555","nullable":true,"type":"string"}},"required":["accessToken","isFauxUser"],"type":"object"},"IntegrationMetadata":{"properties":{"agentLegend":{"anyOf":[{"$ref":"#/components/schemas/AgentLegendIntegration"},{"nullable":true,"type":"object"}],"description":"Agent Legend integration metadata"},"bonzo":{"anyOf":[{"$ref":"#/components/schemas/BonzoIntegration"},{"nullable":true,"type":"object"}],"description":"Bonzo integration metadata"},"sierra":{"anyOf":[{"$ref":"#/components/schemas/SierraIntegration"},{"nullable":true,"type":"object"}],"description":"Sierra integration metadata"}},"type":"object"},"InternalServerError":{"properties":{"message":{"description":"A message describing the error","example":"Internal server error","type":"string"},"statusCode":{"example":500,"type":"number"}},"type":"object"},"InvalidRequest":{"properties":{"message":{"description":"A message describing the error","example":"The parameter leadId must be provided","type":"string"},"statusCode":{"example":400,"type":"number"}},"type":"object"},"NotAuthorized":{"properties":{"message":{"description":"A message describing the error","example":"Access Token is not authorized","type":"string"},"statusCode":{"example":401,"type":"number"}},"type":"object"},"NotFound":{"properties":{"message":{"description":"A message describing the error","example":"Lead not found","type":"string"},"statusCode":{"example":404,"type":"number"}},"type":"object"},"PatchAccount":{"additionalProperties":false,"properties":{"integrations":{"allOf":[{"$ref":"#/components/schemas/PatchAccountIntegrations"}],"description":"Agent Legend auth token and/or API endpoint update. Provide at least one field."}},"required":["integrations"],"type":"object"},"PatchAccountIntegrations":{"additionalProperties":false,"properties":{"agentLegend":{"allOf":[{"$ref":"#/components/schemas/PatchAgentLegendIntegration"}],"description":"Agent Legend auth token and/or API endpoint update. Provide at least one field."}},"required":["agentLegend"],"type":"object"},"PatchAgentLegendIntegration":{"additionalProperties":false,"anyOf":[{"required":["authToken"]},{"required":["apiEndpoint"]}],"properties":{"apiEndpoint":{"description":"HTTPS Agent Legend API base URL override, or null to clear it.","example":"https://tenant.agentlegend.example/api","format":"uri","nullable":true,"type":"string"},"authToken":{"description":"Write-only Agent Legend auth token replacement.","type":"string","writeOnly":true}},"type":"object"},"SierraIntegration":{"properties":{"accessToken":{"description":"A Sierra access token allowing Structurely to access resources for this account","example":"XXXXXXXXXXXXXXXXXXX","type":"string"},"accountId":{"description":"Sierra's unique account ID","example":"sierra-account-12345","type":"string"}},"required":["accessToken","accountId"],"type":"object"}},"securitySchemes":{"bearer-access-token":{"bearerFormat":"JWT","scheme":"bearer","type":"http"}}},"info":{"description":"\n<h2>Overview</h2>\n<p>The Structurely API allows resellers to provide automation for their accounts. It offers various functionalities to streamline account management.</p>\n<p>By utilizing this API, integrators can streamline their workflows.</p>\n\n<h3>Security</h3>\n<p>The Structurely API provides secure authentication and authorization mechanisms to ensure controlled access to its endpoints. The authentication system utilizes API tokens to secure interactions with the API.</p>\n<p>Types of tokens and keys:</p>\n<ul>\n  <li><span class=\"docs-inline-token\">bearer-access-token</span>: Bearer JWT; <b>valid until deactivated</b></li>\n</ul>\n<p><b>Note:</b> It is essential to keep your bearer-access-tokens secure and avoid sharing them with unauthorized parties to maintain the integrity and security of your Structurely API integration.</p>\n</ul>\n","title":"Structurely Reseller v1 API","version":"v3.35.20"},"openapi":"3.0.3","paths":{"/api/reseller/v1/accounts":{"get":{"description":"List active brokerage accounts for the authenticated reseller. Results are sorted by ascending account ID and returned in fixed pages of 25. Supply <span class=\"docs-inline-token\">name</span> only on the initial request; the returned cursor binds the normalized filter and must be used alone for continuation.","parameters":[{"description":"Case-insensitive literal substring filter for the initial account list request.","in":"query","name":"name","required":false,"schema":{"type":"string"}},{"description":"Cursor from a previous account list response. It binds the continuation ID and any normalized name filter, and must be used alone.","in":"query","name":"cursor","required":false,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountListResponse"}}},"description":"Cursor-paginated active brokerage accounts."},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvalidRequest"}}},"description":"Invalid request, check response message"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotAuthorized"}}},"description":"Request is not authorized"},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalServerError"}}},"description":"Internal server error, check response message"}},"security":[{"bearer-access-token":[]}],"summary":"List accounts","tags":["Accounts"]},"post":{"description":"<p>This endpoint will create an account if it does not exist.</p><p>Optionally utilize your system's IDs as internal keys, pass IDs from your CRM or database as parameters for:<ul><li><span class=\"docs-inline-token\">externalAccountId</span>: The Account's ID from your CRM or database</li></ul></p>","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAccount"}}},"description":"New account metadata","required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAccountResponse"}}},"description":"Newly created account"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvalidRequest"}}},"description":"Invalid request, check response message"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotAuthorized"}}},"description":"Request is not authorized"},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalServerError"}}},"description":"Internal server error, check response message"}},"security":[{"bearer-access-token":[]}],"summary":"Create an account","tags":["Accounts"]}},"/api/reseller/v1/accounts/{accountId}":{"delete":{"description":"<p>This endpoint will deactivate an account, this operation is not recoverable, it will disable the AI and account access.</p><p>Optionally utilize your system's IDs as internal keys, pass IDs from your CRM or database as parameters for:<ul><li><span class=\"docs-inline-token\">externalAccountId</span>: The Account's ID from your CRM or database</li></ul></p>","parameters":[{"description":"The Account's ID, either the Structurely Account ID, or the <span class=\"docs-inline-token\">externalAccountId</span> you used when creating the account.","in":"path","name":"accountId","required":true,"schema":{"oneOf":[{"type":"string"},{"format":"ObjectId","type":"string"}]}},{"description":"The reason for archiving the account.","in":"query","name":"reason","required":true,"schema":{"type":"string"}}],"responses":{"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvalidRequest"}}},"description":"Invalid request, check response message"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotAuthorized"}}},"description":"Request is not authorized"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFound"}}},"description":"Resource was not found, check response message"},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalServerError"}}},"description":"Internal server error, check response message"}},"security":[{"bearer-access-token":[]}],"summary":"Archive an account","tags":["Accounts"]},"patch":{"description":"Update the write-only Agent Legend auth token and/or API base URL for an active account owned by the authenticated reseller. Requires the reseller bearer token to include <span class=\"docs-inline-token\">write:accounts</span>. Provide at least one update field.","parameters":[{"description":"The Account's ID, either the Structurely Account ID, or the <span class=\"docs-inline-token\">externalAccountId</span> you used when creating the account.","in":"path","name":"accountId","required":true,"schema":{"oneOf":[{"type":"string"},{"format":"ObjectId","type":"string"}]}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PatchAccount"}}},"description":"Agent Legend auth token and/or API endpoint update. Provide at least one field.","required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Account"}}},"description":"Updated account metadata."},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvalidRequest"}}},"description":"Invalid request, check response message"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotAuthorized"}}},"description":"Request is not authorized"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFound"}}},"description":"Resource was not found, check response message"},"409":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvalidRequest"}}},"description":"The account does not have a configured Agent Legend integration."},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalServerError"}}},"description":"Internal server error, check response message"}},"security":[{"bearer-access-token":[]}],"summary":"Update Agent Legend integration configuration","tags":["Accounts"]}},"/api/reseller/v1/accounts/{accountId}/access-token":{"post":{"description":"Create a new long-lived Direct API token for an active account owned by the authenticated reseller. Requires the reseller bearer token to include <span class=\"docs-inline-token\">write:accounts</span>.","parameters":[{"description":"The Account's ID, either the Structurely Account ID, or the <span class=\"docs-inline-token\">externalAccountId</span> you used when creating the account.","in":"path","name":"accountId","required":true,"schema":{"oneOf":[{"type":"string"},{"format":"ObjectId","type":"string"}]}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAccessToken"}}},"description":"Optional Direct API token scopes.","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAccessTokenResponse"}}},"description":"New Direct API access token and its effective scopes."},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvalidRequest"}}},"description":"Invalid request, check response message"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotAuthorized"}}},"description":"Request is not authorized"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFound"}}},"description":"Resource was not found, check response message"},"409":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountHasNoBrokerError"}}},"description":"The account has no broker available to own the token."},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalServerError"}}},"description":"Internal server error, check response message"}},"security":[{"bearer-access-token":[]}],"summary":"Create a Direct API access token","tags":["Accounts"]}},"/api/reseller/v1/auth/token-info":{"get":{"description":"Retrieve reseller account metadata for an API access token","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountInfo"}}},"description":"Account Metadata"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvalidRequest"}}},"description":"Invalid request, check response message"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotAuthorized"}}},"description":"Request is not authorized"},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalServerError"}}},"description":"Internal server error, check response message"}},"security":[{"bearer-access-token":[]}],"summary":"Retrieve account metadata","tags":["Auth"]}}}}
