Element

Type

Requirement

Description

Additional Note

type

string

Mandatory

Type of contact information. Possible values: "p", "e", "f", "l"

p - primary contact
e - emergency contact
f – financial contact
l – legal contact

email

string

Optional

Email address of the contact.

Should be a valid email format.

companyname

string

Optional

Name of the company.

 

fullname

string

Optional

Full name of the contact person.

 

phone

string

Optional

Phone number of the contact.

 

street1

string

Optional

First line of the contact's street address.

 

street2

string

Optional

Second line of the contact's street address.

 

city

string

Optional

City of the contact's address.

 

zip

string

Optional

ZIP or postal code.

 

state

string

Optional

State, province, or region.

 

country

string

Optional

Country of the contact.

ISO 3166-1 alpha-2 code format (e.g., US, DK).

language

string

Optional

Preferred language of the contact.

Must be ISO639 or ISO639-ISO3166-1 alpha-2 format (e.g., en, en-US). 

Add a contact to the account

Example

Method POST

https://dk-co.keepit.com/users/r4hsnr-ktb74l-bsq8ka/contacts/

Body

<contact>
    <type>l</type>
    <email>test123456789@keepit.com</email>
    <companyname>Company</companyname>
    <fullname>test123456789@keepit.com</fullname>
    <phone>11111111111111</phone>
    <language>en-GB</language>
</contact>

Response

Code: 201 Created

PowerShell script

try {
    $username = '<Token username>'
    $password = '<Token password>'
    $userId = '<Account ID>'

    $basicauth = [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${username}:${password}")) 

    $headers = @{
        "User-Agent"    = "PowerShell-Keepit-API-Agent-1.0"
        "Authorization" = "Basic $basicauth"
        "Content-Type"  = "application/xml"
    }

    $url = "https://dk-co.keepit.com/users/$userId/contacts"

    $xmlBody = @"
<contact>
    <type>l</type>
    <email>test123456789@keepit.com</email>
    <companyname>Company</companyname>
    <fullname>test123456789@keepit.com</fullname>
    <phone>11111111111111</phone>
    <language>en-GB</language>
</contact>
"@

    $response = Invoke-WebRequest -Uri $url -Method POST -Headers $headers -Body $xmlBody -ErrorAction Stop -TimeoutSec 10

    if ($response.StatusCode -eq 201) {
        Write-Host "201 Success"
    }

}
catch {
    $line = $_.InvocationInfo.ScriptLineNumber
    Write-Host "Cannot query Keepit API due to: $_"
    Write-Host "at line $line"
}

Additional information

  • For primary contacts, although email, companyName, and fullName are all optional fields, the email must be provided at a minimum.