{"_id":"55ddc96b9067202b00ddff90","editedParams2":true,"version":{"_id":"55dd9f4dab0e4d210045aae9","__v":39,"project":"55dd9f2e0efd5821000d54d9","createdAt":"2015-08-26T11:13:17.024Z","releaseDate":"2015-08-26T11:13:17.024Z","categories":["55dd9f4dab0e4d210045aaea","55ddb5fa9067202b00ddff6f","55e0472c6bad670d0081f213","55e04764a44fae0d00214671","55e047a9a44fae0d00214672","55e047b258c5460d0076a9a7","55e95e337fc27b2d00d32cf2","55e979bda7ca823900ad549a","55edb8c18dcb210d0056900b","55f0365c8563861700a33765","55f03677d58f9b1900acf996","55f036938eeefc23001ea5de","55f036a38563861700a33767","55f036c08563861700a33769","55f036d02911b72100482cd7","55f036e92911b72100482cd9","55f036fa8563861700a3376b","55f0370ee507711900e58c69","55f0371df6101b1900c70700","55f0374f2911b72100482cdb","55f0375e2911b72100482cdc","560eb0f659cb8d0d0015cd52","560eb25239fad419002ae1e0","561fb64d4d67490d00804b2a","562b9f775a39cd0d009aff22","562ba0505a39cd0d009aff23","562ba149d56bc30d00f0cb18","562ba595f68a5f0d007b1f3b","562ba78fd56bc30d00f0cb1b","562ba8b95a39cd0d009aff27","562baadf6562140d001501d2","562bab37f68a5f0d007b1f3d","562bc1bf9ebc950d000f7523","562bc99ced4bea0d00c11dfa","562bd29c1b98640d00714520","562bd5875a39cd0d009aff60","562bdfabff2da50d002c0aaf","562be0bd5a39cd0d009aff75","57a0b476d8313e1900454439"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"2.0.0","version":"2"},"editedParams":true,"user":"55dd9841cafe7221002a4c62","project":"55dd9f2e0efd5821000d54d9","__v":5,"category":{"_id":"55e047b258c5460d0076a9a7","__v":24,"project":"55dd9f2e0efd5821000d54d9","version":"55dd9f4dab0e4d210045aae9","pages":["55ed71142bdb6a2d0064f216","55ed71e1a872a80d00acff1a","55ed72a8df21af2b009e215f","55ef03aae7f5490d000c0dfd","55f1872e5fe76419007dc703","55f2af86d1c4c7170033df2b","55f2d812525cb12300c6c517","55f2db08c93a2d230062f971","55f2deaacb01c71900c8e218","55f2e024fb7aad2300bf1823","55f2e1f6525cb12300c6c554","55f2e47ffb7aad2300bf182b","55f2ea90525cb12300c6c56c","55f2ed9ecb01c71900c8e24a","55f2f26f71c6462100e0fdf1","55f2f2e3c93a2d230062f9af","55f2f3bdc93a2d230062f9b1","55fc1d6ae013770d008fcbf3","55fc249ff4dbbf0d008f43ef","55fc2bd3e013770d008fcc0b","55ffda3d8c0c9d0d00dcacb4","55ffdf828c0c9d0d00dcacba","55ffe1a56932a00d00ba7abc","560d322c3616cf0d00a8cc97"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-08-28T11:36:18.041Z","from_sync":false,"order":5,"slug":"contacts","title":"Contacts"},"parentDoc":null,"updates":["58db904a7ea7b43700acfcad"],"next":{"pages":[],"description":""},"createdAt":"2015-08-26T14:12:59.486Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","examples":{"codes":[{"language":"csharp","code":"var url = \"/v2/address-books/1/contacts\";\nvar content = :::at:::\"{ email: \"\"john.smith@example.com\"\", optInType: \"\"Single\"\", emailType: \"\"Html\"\", dataFields: [ { key: \"\"FIRSTNAME\"\", value: \"\"John\"\" }, { key: \"\"FULLNAME\"\", value: \"\"John Smith\"\" }, { key: \"\"GENDER\"\", value: \"\"Male\"\" }, { key: \"\"LASTNAME\"\", value: \"\"Smith\"\" }, { key: \"\"POSTCODE\"\", value: \"\"N5 1DP\"\" } ] }\";\nusing (var httpClient = new HttpClient())\n{\n\thttpClient.BaseAddress = new Uri(\"https://api.dotmailer.com\");\n\tvar credentials = Encoding.ASCII.GetBytes(\"username:password\");\n\thttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(\"Basic\", Convert.ToBase64String(credentials));\n\tvar result = httpClient.PostAsync(url, new StringContent(content, Encoding.UTF8, \"application/json\")).Result;\n}","name":""},{"language":"json","code":"{ \n  \"email\": \"john.smith@example.com\",\n  \"optInType\": \"Single\",\n  \"emailType\": \"Html\",\n  \"dataFields\": [\n    {\n      \"key\": \"FIRSTNAME\",\n      \"value\": \"John\"\n    },\n    {\n      \"key\": \"FULLNAME\",\n      \"value\": \"John Smith\"\n    },\n    {\n      \"key\": \"GENDER\",\n      \"value\": \"Male\"\n    },\n    {\n      \"key\": \"LASTNAME\",\n      \"value\": \"Smith\"\n    },\n    {\n      \"key\": \"POSTCODE\",\n      \"value\": \"N5 1DP\"\n    }\n  ]\n} "},{"code":"$content = [\n    'email' => 'john.smith@example.com'\n];\n\n$baseUrl = 'https://api.dotmailer.com';\n$url = $baseUrl . \"/v2/address-books/1/contacts\";\n$ch = curl_init();\ncurl_setopt($ch, CURLOPT_URL, $url);\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\ncurl_setopt(\n    $ch, CURLOPT_HTTPHEADER, array('Accept: application/json',\n                                   'Content-Type: application/json')\n);\ncurl_setopt($ch, CURLAUTH_BASIC, CURLAUTH_DIGEST);\ncurl_setopt(\n    $ch, CURLOPT_USERPWD,\n    $apiUsername . ':' . $apiPassword\n);\ncurl_setopt($ch, CURLOPT_CUSTOMREQUEST, \"POST\");\ncurl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($content));\n\n$response = json_decode(curl_exec($ch));","language":"php"}]},"method":"post","results":{"codes":[{"code":"{\n  \"id\": 1,\n  \"email\": \"john.smith@example.com\",\n  \"optInType\": \"Single\",\n  \"emailType\": \"Html\",\n   \"dataFields\": [\n    {\n      \"key\": \"FIRSTNAME\",\n      \"value\": \"John\"\n    },\n    {\n      \"key\": \"FULLNAME\",\n      \"value\": \"John Smith\"\n    },\n    {\n      \"key\": \"GENDER\",\n      \"value\": \"Male\"\n    },\n    {\n      \"key\": \"LASTNAME\",\n      \"value\": \"Smith\"\n   },\n   {\n      \"key\": \"LASTSUBSCRIBED\",\n      \"value\": \"2016-08-01T10:09:22\"\n    },\n    {\n      \"key\": \"POSTCODE\",\n      \"value\": \"N5 1DP\"\n    }\n  ],\n  \"status\": \"Subscribed\"\n}","language":"json","status":200,"name":""}]},"auth":"required","params":[{"_id":"55ddc96b9067202b00ddff94","ref":"","in":"path","required":true,"desc":"The ID of the address book, which needs to be included within the URL","default":"","type":"int","name":"ID"},{"_id":"55ddc96b9067202b00ddff93","ref":"","in":"body","required":true,"desc":"The email address of the contact, which needs to be included within the request body","default":"","type":"string","name":"Email"},{"_id":"55ddc96b9067202b00ddff92","ref":"","in":"body","required":false,"desc":"The opt-in type of the contact, which needs to be included within the request body","default":"'Unknown', 'Single', 'Double', 'VerifiedDouble'","type":"string","name":"OptInType"},{"_id":"55ddc96b9067202b00ddff91","ref":"","in":"body","required":false,"desc":"The email type of the contact, which needs to be included within the request body","default":"'PlainText', 'Html'","type":"string","name":"EmailType"},{"_id":"55ddcb4a9067202b00ddff96","ref":"","in":"body","required":false,"desc":"Each contact data field is a key-value pair; the key is a string. It needs to be included within the request body.","default":"","type":"string","name":"DataFields.Key"},{"_id":"568a87bad4e2360d00980039","ref":"","in":"body","required":false,"desc":"Each contact data field is a key-value pair; the value can be of any type. It needs to be included within the request body.","default":"","type":"mixed","name":"DataFields.Value"}],"url":"/v:version/address-books/[ID]/contacts"},"isReference":false,"order":3,"body":"This operation adds a contact to a given address book. The contact can be new or existing. If the contact already exists, then any data provided in your request that is already held for the contact will be overwritten and updated in the system.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"If you're looking to import or update multiple contacts to an address book at once, then we highly recommend using [Bulk create contacts in address book](https://developer.dotmailer.com/docs/bulk-create-contacts-in-address-book) instead.\\n\\nIt allows you to import a file and has the benefit of being a single API call only, making it far less likely that your account will exceed its API calls per hour limit.\",\n  \"title\": \"Are you importing multiple contacts?\"\n}\n[/block]","excerpt":"Adds a contact to a given address book","slug":"add-contact-to-address-book","type":"endpoint","title":"Add contact to address book"}

postAdd contact to address book

Adds a contact to a given address book

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Path Params

ID:
required
integer
The ID of the address book, which needs to be included within the URL

Body Params

Email:
required
string
The email address of the contact, which needs to be included within the request body
OptInType:
string'Unknown', 'Single', 'Double', 'VerifiedDouble'
The opt-in type of the contact, which needs to be included within the request body
EmailType:
string'PlainText', 'Html'
The email type of the contact, which needs to be included within the request body
DataFields.Key:
string
Each contact data field is a key-value pair; the key is a string. It needs to be included within the request body.
DataFields.Value:
mixed
Each contact data field is a key-value pair; the value can be of any type. It needs to be included within the request body.

Examples


Result Format


Documentation

This operation adds a contact to a given address book. The contact can be new or existing. If the contact already exists, then any data provided in your request that is already held for the contact will be overwritten and updated in the system. [block:callout] { "type": "info", "body": "If you're looking to import or update multiple contacts to an address book at once, then we highly recommend using [Bulk create contacts in address book](https://developer.dotmailer.com/docs/bulk-create-contacts-in-address-book) instead.\n\nIt allows you to import a file and has the benefit of being a single API call only, making it far less likely that your account will exceed its API calls per hour limit.", "title": "Are you importing multiple contacts?" } [/block]