DirectAddressValidate
Validates a direct address supplied either as a raw address, or as an Updox 'recipient'
Prerequisites
This API call requires
Application Credentials
and an Account Identifier
.
The credentials should be populated into the applicationId
and applicationPassword
fields, and the identifier should be populated into the accountId
field of the auth block.
...
"auth": {
"applicationId": "updox",
"applicationPassword": "1234567890",
"accountId": "account"
}
...
Direct Domain Certificate Types
When a call is made to /DirectAddressValidate, a search is performed
for a current, non-revoked certificate for the target Direct address. There are two types of
certificate searches:
Address-Level Certificates
The first certificate search looks for a certificate issued for the full recipient address:
DrTom@DrTomsPractice.MyEHRDirect.com. If all of the following
are true, then /DirectAddressValidate will return
"validDirectAddress": true:
- - a certificate is found (either via DNS or LDAP)
- - the found certificate has not been revoked
- - the found certificate is trusted itself or is signed by a trusted TrustAnchor
- - the found certificate is either:
- - not signed by DirectTrust or
- - signed by DirectTrust and the inquiring user's practice has been "vetted"
Domain-Level Certificates
If no valid certificate can be found for the address, the next certificate search will be performed
on the domain of the intended recipient: DrBobsPractice.OtherEHRDirect.com.
A Domain-level certificate is used for all users in a given domain. The same certificate will be
used to sign messages from DrBob@DrBobsPractice.OtherEHRDirect.com
and messages from NurseRatchett@DrBobsPractice.OtherEHRDirect.com.
Since there are not any user-specific (aka Address-specific) certificates available to be searched,
the most precise anyone can be about determining if the recipient Direct address exists is to
confirm the existence of a trusted, non-revoked certificate for the domain. The requirements for a
Domain-Level certificate to be valid also apply to an Address-Level certificate:
- - a certificate is found (either via DNS or LDAP)
- - the found certificate has not been revoked
- - the found certificate is trusted itself or is signed by a trusted TrustAnchor
- - the found certificate is either:
- - not signed by DirectTrust or
- - signed by DirectTrust and the inquiring user's practice has been "vetted"
IMPORTANT NOTE: A response from /DirectAddressValidate
of "validDirectAddress": true does not mean that the address itself
is guaranteed to exist or that messages sent to it will be picked up by the intended recipient -- only
that a valid, non-revoked, trusted certificate can be found for the requested address or domain.
For information about delivery confirmation, read about MDN processing.
Special Case
If all of the following are true:
- - a valid address-level or domain-level certificate is found
- - the certificate is signed by DirectTrust
- - the inquiring user's practice has not been "vetted"
then the following values will be included in the
/DirectAddressValidate response:
....
"validDirectAddress": false,
"vettingRequired": true,
...
This means that in order for the inquiring user to be able to send messages to the specified address,
their practice must go through the Direct Trust Activation process. Once that process is completed and
the practice is "vetted", the same call to
/DirectAddressValidate
will return the expected:
....
"validDirectAddress": true,
...
Code Samples
Fullscreen
Copy to clipboard
/*
* DISCLAIMER:
* Updox provides programming examples for demonstration purposes only,
* without warranty either expressed or implied, including, but not limited to,
* the implied warranties of merchantability or fitness for a particular purpose.
* These code samples assume that you are familiar with the programming
* language that is being demonstrated and the tools that are used to run them.
*
* NOTE:
* This source code sample was dynamically generated from the corresponding
* request and response objects. This process can be complex and may not
* always generate source code that is ready for compilation. Please be aware
* that slight tweaking of the code sample may be necessary.
*/
using System;
using System.IO;
using System.Net;
using System.Web.Script.Serialization;
using System.Collections.Generic;
namespace Updox_Tester {
public class UpdoxCodeSample_DirectAddressValidate {
public static void Main(string[] args) {
try {
UpdoxCodeSample_DirectAddressValidate codeSample = new UpdoxCodeSample_DirectAddressValidate();
codeSample.execute();
} catch (Exception ex) {
System.Diagnostics.Debug.WriteLine(ex.StackTrace);
}
}
public void execute() {
string environment = "https://updoxqa.com/api/io/";
String methodName = "DirectAddressValidate";
DirectAddressValidateRequest directAddressValidateRequest = new DirectAddressValidateRequest();
//set up credentials
directAddressValidateRequest.auth.applicationId = "applicationId";
directAddressValidateRequest.auth.applicationPassword = "applicationPassword";
directAddressValidateRequest.auth.accountId = "accountId";
//set up request specific parameters
directAddressValidateRequest.recipient = "recipient";
directAddressValidateRequest.includeLoA = true;
//create the request
string json = Utilities.buildRequestJson(directAddressValidateRequest);
//send the request and get the response
string jsonResponse = Utilities.callApi(environment, "DirectAddressValidate", json);
//reconstitute the response into an object
JavaScriptSerializer javascriptSerializer = new JavaScriptSerializer();
DirectAddressValidateResponse directAddressValidateResponse = javascriptSerializer.Deserialize<DirectAddressValidateResponse>(jsonResponse);
Console.WriteLine(directAddressValidateResponse.responseCode);
Console.WriteLine(directAddressValidateResponse.responseMessage);
Environment.Exit (0);
}
public class DirectAddressValidateRequest : UpdoxRequest {
public string recipient { get; set;}
public bool includeLoA { get; set;}
}
public class UpdoxAuth {
public string applicationId { get; set;}
public string applicationPassword { get; set;}
public string accountId { get; set;}
public string userId { get; set;}
}
public class UpdoxRequest {
public UpdoxRequest() {
this.auth = new UpdoxAuth();
}
public UpdoxAuth auth { get; set;}
}
public class DirectAddressValidateResponse : UpdoxResponse {
public string recipient { get; set;}
public string name { get; set;}
public string directAddress { get; set;}
public bool validDirectAddress { get; set;}
public bool vettingRequired { get; set;}
public string reason { get; set;}
}
public class UpdoxResponse {
public bool successful { get; set;}
public string responseMessage { get; set;}
public long responseCode { get; set;}
}
public static class Utilities {
public static string buildRequestJson(UpdoxRequest request) {
string json = new JavaScriptSerializer().Serialize(request);
return json;
}
public static HttpWebResponse sendRequest(string json, string url) {
var httpWebRequest = HttpWebRequest.Create(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) {
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
var httpResponse = (HttpWebResponse) httpWebRequest.GetResponse();
return httpResponse;
}
}
public static string callApi(string environment, string methodName, string json) {
string url = environment + methodName;
HttpWebResponse httpResponse = sendRequest (json, url);
if (httpResponse == null)
throw new ArgumentNullException("response");
Stream dataStream = null;
StreamReader reader = null;
string responseFromServer = null;
try {
dataStream = httpResponse.GetResponseStream();
reader = new StreamReader(dataStream);
responseFromServer = reader.ReadToEnd();
} catch (Exception ex) {
Console.WriteLine(ex.Message);
} finally {
if (reader != null)
reader.Close();
if (dataStream != null)
dataStream.Close();
httpResponse.Close();
}
return responseFromServer;
}
}
}
}
package test;
/*
* DISCLAIMER:
* Updox provides programming examples for demonstration purposes only,
* without warranty either expressed or implied, including, but not limited to,
* the implied warranties of merchantability or fitness for a particular purpose.
* These code samples assume that you are familiar with the programming
* language that is being demonstrated and the tools that are used to run them.
*
* NOTE:
* This source code sample was dynamically generated from the corresponding
* request and response objects. This process can be complex and may not
* always generate source code that is ready for compilation. Please be aware
* that slight tweaking of the code sample may be necessary.
*/
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import java.io.Serializable;
public class UpdoxCodeSample_DirectAddressValidate {
public static void main(String[] args) {
UpdoxCodeSample_DirectAddressValidate codeSample = new UpdoxCodeSample_DirectAddressValidate();
try {
codeSample.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
public void execute() throws Exception {
String methodName = "DirectAddressValidate";
DirectAddressValidateRequest directAddressValidateRequest = new DirectAddressValidateRequest();
//set environment and credentials - QA
String environment = "https://updoxqa.com/api/io/";
UpdoxRequest auth = directAddressValidateRequest.getAuth();
auth.setApplicationId("applicationId");
auth.setApplicationPassword("applicationPassword");
auth.setAccountId("accountId");
directAddressValidateRequest.setRecipient("recipient");
directAddressValidateRequest.setIncludeLoA(true);
//create the request
String jsonRequest = Utilities.buildRequestJson(directAddressValidateRequest);
//send the request
String jsonResponse = Utilities.callApi(environment, 'DirectAddressValidate', jsonRequest);
//reconstitute the response into an object
ObjectMapper mapper = new ObjectMapper();
DirectAddressValidateResponse directAddressValidateResponse = mapper.readValue(jsonResponse, DirectAddressValidateResponse.class);
System.out.println(directAddressValidateResponse.getResponseCode());
System.out.println(directAddressValidateResponse.getResponseMessage());
}
private class DirectAddressValidateRequest extends UpdoxRequest {
private UpdoxRequest auth = new UpdoxRequest();
private String recipient;
private boolean includeLoA;
public UpdoxRequest getAuth() {
return auth;
}
public void setAuth(UpdoxRequest auth) {
this.auth = auth;
}
public String getRecipient() {
return recipient;
}
public void setRecipient(String recipient) {
this.recipient = recipient;
}
public boolean isIncludeLoA() {
return includeLoA;
}
public void setIncludeLoA(boolean includeLoA) {
this.includeLoA = includeLoA;
}
}
private class UpdoxRequest implements Serializable {
private String applicationId;
private String applicationPassword;
private String accountId;
public String getApplicationId() {
return applicationId;
}
public void setApplicationId(String applicationId) {
this.applicationId = applicationId;
}
public String getApplicationPassword() {
return applicationPassword;
}
public void setApplicationPassword(String applicationPassword) {
this.applicationPassword = applicationPassword;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
}
private static class DirectAddressValidateResponse extends UpdoxResponse {
private String recipient;
private String name;
private String directAddress;
private boolean validDirectAddress;
private boolean vettingRequired;
private String reason;
public String getRecipient() {
return recipient;
}
public void setRecipient(String recipient) {
this.recipient = recipient;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDirectAddress() {
return directAddress;
}
public void setDirectAddress(String directAddress) {
this.directAddress = directAddress;
}
public boolean isValidDirectAddress() {
return validDirectAddress;
}
public void setValidDirectAddress(boolean validDirectAddress) {
this.validDirectAddress = validDirectAddress;
}
public boolean isVettingRequired() {
return vettingRequired;
}
public void setVettingRequired(boolean vettingRequired) {
this.vettingRequired = vettingRequired;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
}
private static class UpdoxResponse implements Serializable {
private boolean successful;
private String responseMessage;
private long responseCode;
public boolean isSuccessful() {
return successful;
}
public void setSuccessful(boolean successful) {
this.successful = successful;
}
public String getResponseMessage() {
return responseMessage;
}
public void setResponseMessage(String responseMessage) {
this.responseMessage = responseMessage;
}
public long getResponseCode() {
return responseCode;
}
public void setResponseCode(long responseCode) {
this.responseCode = responseCode;
}
}
private static class Utilities {
public static String buildRequestJson(Object object) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
return mapper.writeValueAsString(object);
}
public static String callApi(String environment, String methodName, String json) throws Exception {
String uri = environment + methodName;
HttpClient httpClient = new DefaultHttpClient();
String result = null;
StringEntity params = new StringEntity(json);
try {
HttpPost request = new HttpPost(uri);
request.addHeader("content-type", "application/json");
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
result = EntityUtils.toString(response.getEntity());
} catch (Exception ex) {
// handle exception here
} finally {
httpClient.getConnectionManager().shutdown();
}
return result;
}
}
}
General Response Codes
The General Response Code Set is the set of response codes that is possible in any API response. Examples include general validation errors, authentication errors, or server errors.
ResponseCode |
ResponseMessage |
2000 |
OK |
4000 |
Bad Request |
4010 |
Unauthorized |
4011 |
Unauthorized [Practice does not exist, is inactive, or is not authorized for this action] |
4012 |
Unauthorized [User does not exist, is inactive, or is not authorized for this action] |
4060 |
A validation error in the request. For example not including a required field, an invalid e-mail address, too long of a value, etc. A list of the errors is included in the message. |
5000 |
an unknown error has occurred |
5100 |
an unknown server error has occurred |
5110 |
an unknown server error has occurred |