Chilkat Online Tools

SQL Server / Bond APIs / create a business

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    -- Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    -- The following JSON is sent in the request body.

    -- {
    --   "ein": "12-1234567",
    --   "phone": "+1408-555-7788",
    --   "email": "user@example.com",
    --   "website": "https://www.specter.com",
    --   "legal_business_name": "World Domination Inc.",
    --   "dba_business_name": "World Domination Inc.",
    --   "business_type": "limited_liability_company",
    --   "addresses": [
    --     {
    --       "address_type": "MAILING",
    --       "street": "345 California Ave.",
    --       "street2": "Suit 600",
    --       "city": "San Francisco",
    --       "state": "CA",
    --       "zip_code": "12345-1234",
    --       "country": "US",
    --       "is_primary": false
    --     },
    --     {
    --       "address_type": "PHYSICAL",
    --       "street": "123 California Ave.",
    --       "street2": "Suit 100",
    --       "city": "San Francisco",
    --       "state": "CA",
    --       "zip_code": "12345-1234",
    --       "country": "US",
    --       "is_primary": true
    --     }
    --   ],
    --   "beneficial_owners": [
    --     {
    --       "first_name": "James",
    --       "last_name": "Bond",
    --       "dob": "1970-12-12",
    --       "addresses": [
    --         {
    --           "address_type": "MAILING",
    --           "street": "345 California Ave.",
    --           "street2": "Suit 600",
    --           "city": "San Francisco",
    --           "state": "CA",
    --           "zip_code": "12345-1234",
    --           "country": "US",
    --           "is_primary": true
    --         }
    --       ]
    --     },
    --     {
    --       "first_name": "Le",
    --       "last_name": "Chiffre",
    --       "dob": "1980-04-04",
    --       "addresses": [
    --         {
    --           "address_type": "MAILING",
    --           "street": "345 California Ave.",
    --           "street2": "Suit 600",
    --           "city": "San Francisco",
    --           "state": "CA",
    --           "zip_code": "12345-1234",
    --           "country": "US",
    --           "is_primary": true
    --         }
    --       ]
    --     }
    --   ]
    -- }

    DECLARE @json int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT

    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'ein', '12-1234567'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'phone', '+1408-555-7788'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'email', 'user@example.com'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'website', 'https://www.specter.com'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'legal_business_name', 'World Domination Inc.'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'dba_business_name', 'World Domination Inc.'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'business_type', 'limited_liability_company'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[0].address_type', 'MAILING'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[0].street', '345 California Ave.'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[0].street2', 'Suit 600'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[0].city', 'San Francisco'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[0].state', 'CA'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[0].zip_code', '12345-1234'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[0].country', 'US'
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'addresses[0].is_primary', 0
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[1].address_type', 'PHYSICAL'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[1].street', '123 California Ave.'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[1].street2', 'Suit 100'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[1].city', 'San Francisco'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[1].state', 'CA'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[1].zip_code', '12345-1234'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[1].country', 'US'
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'addresses[1].is_primary', 1
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[0].first_name', 'James'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[0].last_name', 'Bond'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[0].dob', '1970-12-12'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[0].addresses[0].address_type', 'MAILING'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[0].addresses[0].street', '345 California Ave.'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[0].addresses[0].street2', 'Suit 600'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[0].addresses[0].city', 'San Francisco'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[0].addresses[0].state', 'CA'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[0].addresses[0].zip_code', '12345-1234'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[0].addresses[0].country', 'US'
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'beneficial_owners[0].addresses[0].is_primary', 1
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[1].first_name', 'Le'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[1].last_name', 'Chiffre'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[1].dob', '1980-04-04'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[1].addresses[0].address_type', 'MAILING'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[1].addresses[0].street', '345 California Ave.'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[1].addresses[0].street2', 'Suit 600'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[1].addresses[0].city', 'San Francisco'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[1].addresses[0].state', 'CA'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[1].addresses[0].zip_code', '12345-1234'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'beneficial_owners[1].addresses[0].country', 'US'
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'beneficial_owners[1].addresses[0].is_primary', 1

    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Authorization', '{{authorization}}'
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Identity', '{{identity}}'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://{{environment}}.bond.tech/api/v0/businesses', 'application/json', @json
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @json
        RETURN
      END

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT @iTmp0
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    PRINT @sTmp0
    EXEC @hr = sp_OADestroy @resp


    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @json


END
GO

Curl Command

curl -X POST
	-H "Authorization: {{authorization}}"
	-H "Identity: {{identity}}"
	-d '{
    "ein": "12-1234567",
    "phone": "+1408-555-7788",
    "email": "user@example.com",
    "website": "https://www.specter.com",
    "legal_business_name": "World Domination Inc.",
    "dba_business_name": "World Domination Inc.",
    "business_type": "limited_liability_company",
    "addresses": [
    {
        "address_type": "MAILING",
        "street": "345 California Ave.",
        "street2": "Suit 600",
        "city": "San Francisco",
        "state": "CA",
        "zip_code": "12345-1234",
        "country": "US",
        "is_primary": false    
    },
    {
        "address_type": "PHYSICAL",
        "street": "123 California Ave.",
        "street2": "Suit 100",
        "city": "San Francisco",
        "state": "CA",
        "zip_code": "12345-1234",
        "country": "US",
        "is_primary": true
    }
    ],
    "beneficial_owners": [
    {
        "first_name": "James",
        "last_name": "Bond",
        "dob": "1970-12-12",
        "addresses": [
        {
            "address_type": "MAILING",
            "street": "345 California Ave.",
            "street2": "Suit 600",
            "city": "San Francisco",
            "state": "CA",
            "zip_code": "12345-1234",
            "country": "US",
            "is_primary": true
        }
        ]
    },
    {
        "first_name": "Le",
        "last_name": "Chiffre",
        "dob": "1980-04-04",
        "addresses": [
        {
            "address_type": "MAILING",
            "street": "345 California Ave.",
            "street2": "Suit 600",
            "city": "San Francisco",
            "state": "CA",
            "zip_code": "12345-1234",
            "country": "US",
            "is_primary": true
        }
        ]
    }
    ]
}'
https://{{environment}}.bond.tech/api/v0/businesses

Postman Collection Item JSON

{
  "name": "create a business",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Authorization",
        "value": "{{authorization}}",
        "type": "text"
      },
      {
        "key": "Identity",
        "value": "{{identity}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"ein\": \"12-1234567\",\n    \"phone\": \"+1408-555-7788\",\n    \"email\": \"user@example.com\",\n    \"website\": \"https://www.specter.com\",\n    \"legal_business_name\": \"World Domination Inc.\",\n    \"dba_business_name\": \"World Domination Inc.\",\n    \"business_type\": \"limited_liability_company\",\n    \"addresses\": [\n    {\n        \"address_type\": \"MAILING\",\n        \"street\": \"345 California Ave.\",\n        \"street2\": \"Suit 600\",\n        \"city\": \"San Francisco\",\n        \"state\": \"CA\",\n        \"zip_code\": \"12345-1234\",\n        \"country\": \"US\",\n        \"is_primary\": false    \n    },\n    {\n        \"address_type\": \"PHYSICAL\",\n        \"street\": \"123 California Ave.\",\n        \"street2\": \"Suit 100\",\n        \"city\": \"San Francisco\",\n        \"state\": \"CA\",\n        \"zip_code\": \"12345-1234\",\n        \"country\": \"US\",\n        \"is_primary\": true\n    }\n    ],\n    \"beneficial_owners\": [\n    {\n        \"first_name\": \"James\",\n        \"last_name\": \"Bond\",\n        \"dob\": \"1970-12-12\",\n        \"addresses\": [\n        {\n            \"address_type\": \"MAILING\",\n            \"street\": \"345 California Ave.\",\n            \"street2\": \"Suit 600\",\n            \"city\": \"San Francisco\",\n            \"state\": \"CA\",\n            \"zip_code\": \"12345-1234\",\n            \"country\": \"US\",\n            \"is_primary\": true\n        }\n        ]\n    },\n    {\n        \"first_name\": \"Le\",\n        \"last_name\": \"Chiffre\",\n        \"dob\": \"1980-04-04\",\n        \"addresses\": [\n        {\n            \"address_type\": \"MAILING\",\n            \"street\": \"345 California Ave.\",\n            \"street2\": \"Suit 600\",\n            \"city\": \"San Francisco\",\n            \"state\": \"CA\",\n            \"zip_code\": \"12345-1234\",\n            \"country\": \"US\",\n            \"is_primary\": true\n        }\n        ]\n    }\n    ]\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "https://{{environment}}.bond.tech/api/v0/businesses",
      "protocol": "https",
      "host": [
        "{{environment}}",
        "bond",
        "tech"
      ],
      "path": [
        "api",
        "v0",
        "businesses"
      ],
      "query": [
        {
          "key": "page",
          "value": "2",
          "disabled": true
        },
        {
          "key": "per_page",
          "value": "5",
          "disabled": true
        }
      ]
    },
    "description": "Retrieve Card to Card Transfer"
  },
  "response": [
    {
      "name": "example",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "{{authorization}}",
            "type": "text"
          },
          {
            "key": "Identity",
            "value": "{{identity}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "name": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"ein\": \"12-1234567\",\n    \"phone\": \"+14085557788\",\n    \"email\": \"user@example.com\",\n    \"website\": \"https://www.specter.com\",\n    \"legal_business_name\": \"World Domination Inc.\",\n    \"dba_business_name\": \"World Domination Inc.\",\n    \"business_type\": \"FinTech\",\n    \"address\": [\n    {\n        \"address_type\": \"MAILING\",\n        \"street\": \"345 California Ave.\",\n        \"street2\": \"Suit 600\",\n        \"city\": \"San Francisco\",\n        \"state\": \"CA\",\n        \"zip_code\": \"12345-1234\",\n        \"country\": \"US\",\n        \"is_primary\": true    \n    },\n    {\n        \"address_type\": \"PHYSICAL\",\n        \"street\": \"123 California Ave.\",\n        \"street2\": \"Suit 100\",\n        \"city\": \"San Francisco\",\n        \"state\": \"CA\",\n        \"zip_code\": \"12345-1234\",\n        \"country\": \"US\",\n        \"is_primary\": true\n    }\n    ],\n    \"beneficial_owners\": [\n    {\n        \"first_name\": \"James\",\n        \"last_name\": \"Bond\",\n        \"dob\": \"1970-12-12\",\n        \"date_created\": \"2019-08-24T14:15:22Z\",\n        \"date_updated\": \"2019-08-24T14:15:22Z\",\n        \"address\": [\n        {\n            \"address_type\": \"MAILING\",\n            \"street\": \"345 California Ave.\",\n            \"street2\": \"Suit 600\",\n            \"city\": \"San Francisco\",\n            \"state\": \"CA\",\n            \"zip_code\": \"12345-1234\",\n            \"country\": \"US\",\n            \"is_primary\": true\n        }\n        ]\n    },\n    {\n        \"first_name\": \"Le\",\n        \"last_name\": \"Chiffre\",\n        \"dob\": \"1980-04-04\",\n        \"address\": [\n        {\n            \"address_type\": \"MAILING\",\n            \"street\": \"345 California Ave.\",\n            \"street2\": \"Suit 600\",\n            \"city\": \"San Francisco\",\n            \"state\": \"CA\",\n            \"zip_code\": \"12345-1234\",\n            \"country\": \"US\",\n            \"is_primary\": true\n        }\n        ]\n    }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "https://{{environment}}.bond.tech/api/v0/businesses/\n",
          "protocol": "https",
          "host": [
            "{{environment}}",
            "bond",
            "tech"
          ],
          "path": [
            "api",
            "v0",
            "businesses",
            "\n"
          ],
          "query": [
            {
              "key": "card_account_id",
              "value": "b18f94bc-0d7c-456e-a2e7-19e68393b64f",
              "disabled": true
            }
          ]
        }
      },
      "_postman_previewlanguage": "json",
      "header": null,
      "cookie": [
      ],
      "body": "{\n    \"business_id\": \"96df8579-5d05-4e3e-a5e3-e61e3a5bdb38\",\n    \"ein\": \"12-1234567\",\n    \"phone\": \"+14085557788\",\n    \"email\": \"user@example.com\",\n    \"website\": \"https://www.specter.com\",\n    \"legal_business_name\": \"World Domination Inc.\",\n    \"dba_business_name\": \"World Domination Inc.\",\n    \"business_type\": \"FinTech\",\n    \"date_updated\": \"2019-08-24T14:15:22Z\",\n    \"date_created\": \"2019-08-24T14:15:22Z\",\n    \"address\": [\n    {\n        \"date_updated\": \"2019-08-24T14:15:22Z\",\n        \"date_created\": \"2019-08-24T14:15:22Z\",\n        \"address_id\": \"12348579-5d05-4e3e-a5e3-e61e3a5b1234\",\n        \"address_type\": \"MAILING\",\n        \"street\": \"345 California Ave.\",\n        \"street2\": \"Suit 600\",\n        \"city\": \"San Francisco\",\n        \"state\": \"CA\",\n        \"zip_code\": \"12345-1234\",\n        \"country\": \"US\",\n        \"is_primary\": True,\n        \"deliverability\": \"deliverable\"\n    },\n    {\n        \"date_updated\": \"2019-08-24T14:15:22Z\",\n        \"date_created\": \"2019-08-24T14:15:22Z\",\n        \"address_id\": \"67898579-5d05-6789-a5e3-e61e3a5b6789\",\n        \"address_type\": \"PHYSICAL\",\n        \"street\": \"123 California Ave.\",\n        \"street2\": \"Suit 100\",\n        \"city\": \"San Francisco\",\n        \"state\": \"CA\",\n        \"zip_code\": \"12345-1234\",\n        \"country\": \"US\",\n        \"is_primary\": False,\n        \"deliverability\": \"undeliverable\"\n    }\n    ],\n    \"beneficial_owners\": [\n    {\n        \"beneficial_owner_id\": \"45628579-5d05-4562-a5e3-e61e3a5b4562\",\n        \"first_name\": \"James\",\n        \"last_name\": \"Bond\",\n        \"dob\": \"1970-12-12\",\n        \"date_created\": \"2019-08-24T14:15:22Z\",\n        \"date_updated\": \"2019-08-24T14:15:22Z\",\n        \"address\": [\n        {\n            \"address_id\": \"12347777-5d05-4e3e-a5e3-e61e3a5b7777\",\n            \"address_type\": \"MAILING\",\n            \"street\": \"345 California Ave.\",\n            \"street2\": \"Suit 600\",\n            \"city\": \"San Francisco\",\n            \"state\": \"CA\",\n            \"zip_code\": \"12345-1234\",\n            \"country\": \"US\",\n            \"is_primary\": True,\n            \"deliverability\": \"deliverable\"\n        }\n        ]\n    },\n    {\n        \"beneficial_owner_id\": \"12345678-5d05-4562-a5e3-e61e12345678\",\n        \"first_name\": \"Le\",\n        \"last_name\": \"Chiffre\",\n        \"dob\": \"1980-04-04\",\n        \"date_created\": \"2019-08-24T14:15:22Z\",\n        \"date_updated\": \"2019-08-24T14:15:22Z\",\n        \"address\": [\n        {\n            \"date_updated\": \"2019-08-24T14:15:22Z\",\n            \"date_created\": \"2019-08-24T14:15:22Z\",\n            \"address_id\": \"88887777-5d05-4e3e-a5e3-e61e88887777\",\n            \"address_type\": \"MAILING\",\n            \"street\": \"345 California Ave.\",\n            \"street2\": \"Suit 600\",\n            \"city\": \"San Francisco\",\n            \"state\": \"CA\",\n            \"zip_code\": \"12345-1234\",\n            \"country\": \"US\",\n            \"is_primary\": True,\n            \"deliverability\": \"deliverable\"\n        }\n        ]\n    }\n    ]\n}"
    }
  ]
}