ATS API Implementation Guide for Mobile Publishers

This article outlines the steps to implement the ATS Envelope API to retrieve and manage consented envelopes for mobile use cases.

⚠️

Migrating from ATS Mobile SDK

The ATS Mobile SDK has been sunset and can no longer retrieve envelopes or pass them to Google Secure Signals. If your app used the deprecated ATS Mobile SDK, replace its envelope retrieval and refresh capabilities with the ATS Envelope API, then reconnect each downstream partner the SDK fed.

Follow the ATS Mobile SDK Migration Checklist to learn what you need to do to complete your migration.

Server-Side Operation Recommended

We recommend handling as much of the ATS API workflow as possible on your backend. This reduces reliance on outgoing third-party requests from the device and makes your integration more resilient to future platform restrictions.

You can configure your backend to handle:

  • Identifier normalization and hashing.
  • Envelope retrieval, lifecycle tracking, and refreshes.
  • Consent validation.

While your app still handles the following:

  • Supplies the envelope to your partner SDKs or the Google adapter.
  • Checks envelope eligibility and expiry, and clears cached envelopes immediately when the user logs out or changes privacy choices.
ℹ️

If a backend implementation isn't possible, you can call LiveRamp directly from the app as a fallback, in which case your app owns retrieval, refresh, metadata, and protection against stale responses.

1. Create an ATS Placement in Console

Create an ATS placement in LiveRamp Console to obtain a Placement ID that will be used in your ATS requests. During this process, you must include the bundle IDs and the countries/regions where you want to run ATS. Note that your ATS placement must be in an 'Approved' state to retrieve valid envelopes.

To learn how you can obtain a Placement ID, see "Create an ATS Placement".

2. Collect Consent and Prepare Identifiers

Based on the user's location, ATS Envelope API may require a standardized consent string to retrieve envelopes. Make sure you have a proper Consent Management Platform (CMP) in place that can provide a valid consent string.

See the requirement for each region below:

RegionRequirements
EU/EEA and UKA valid TCF v2.3-compatible consent string with positive consent for LiveRamp.
USApplicable GPP signals and honor the user's privacy choices.
Other countriesNo standardized consent string required. Applicable privacy requirements and user choices still apply.
iOS (all regions)App Tracking Transparency (ATT) authorization. ATT and regional consent strings are separate requirements, and one doesn't replace the other.

For more information, see "Provide a Valid Consent String".

Supported Identifier Types

The table below lists all supported identifier types and the relevant it value to pass in your request.

IdentifieritRequirements
Hashed email4Use SHA-256, SHA-1, or MD5. If you can send only one hash type, use SHA-256.
Hashed phone (US only)11Use a US ten-digit number without a country code, hashed with SHA-1.
Custom ID15Contact a LiveRamp representative to allow passing custom ID as identifiers.

Normalization Guidelines

Normalize each identifier before hashing it, and don't hash malformed input. We recommend doing this on your backend. The Swift examples below show the same steps if you need to do it in your app using Foundation and CryptoKit (iOS 13+).

  • Email: Remove whitespace, convert to lowercase, remove the plus extension (+tag), and remove dots from Gmail usernames.
  • Phone (US only): Remove formatting characters and the +1 country code, and confirm the result is exactly ten digits. Reject extensions and avoid treating international numbers as US numbers because they have ten digits. For international or free-form input, use a validated phone-number library.

For more information, see "Prepare the Identifiers".

Email Normalization Example (iOS)

This example validates conservatively and isn't a full RFC email parser. If you accept a broader range of addresses, use a validated normalization library that follows LiveRamp's identifier guidance.

import Foundation
import CryptoKit

func normalizeEmail(_ input: String) -> String? {
    let cleaned = input.components(separatedBy: .whitespacesAndNewlines)
        .joined().lowercased()
    let parts = cleaned.split(separator: "@", omittingEmptySubsequences: false)
    guard parts.count == 2 else { return nil }
    var lo
US Phone Normalization Example (iOS)
// Uses the Foundation/CryptoKit imports and hexDigest helper above.
func normalizeUSPhone(_ input: String, isUSNumber: Bool) -> String? {
    guard isUSNumber else { return nil }
    let allowed = CharacterSet(charactersIn: "+0123456789 ()-.")
    guard input.unicodeScalars.allSatisfy({ allowed.contains($0) }) else {
        return nil
    }
    let compact = input.components(separatedBy:
        CharacterSet(charactersIn: " ()-.")).joined()
    guard !compact.hasPrefix("+") || compact.hasPrefix("+1") else {
        return nil
    }
    guard !compact.dropFirst().contains("+") else { return nil }
    var digits = compact.filter { $0 >= "0" && $0 <= "9" }
    guard !compact.hasPrefix("+") || digits.count == 11 else { return nil }
    if digits.count == 11 && digits.hasPrefix("1") {
        digits.removeFirst()
    }
    guard digits.count == 10 else { return nil }
    return digits
}

if let phone = normalizeUSPhone("+1 (555) 123-4567", isUSNumber: true) {
    // Normalized value: 5551234567 (no country code).
    let identifier = hexDigest(Insecure.SHA1.hash(data: Data(phone.utf8)))
    // Supply identifier as iv with it=11. Never log identifiers.
}

4. Retrieve the ATS Envelope

Call the following endpoint to retrieve an ATS envelope by supplying your placement ID, prepared identifier, and applicable consent string:

GET https://api.rlcdn.com/api/identity/v2/envelope

For more information , see "Call the ATS Envelope API" .

Parameters
ParameterTypeValue
pidint32Your Placement ID.
itint32The identifier type of the call:
  • "4" corresponds to hashed emails.
  • "11" corresponds to phone number hashes.
  • "15" corresponds to custom IDs. Learn more about Custom IDs Support.
ivstring

The hashed version of the raw email or phone number.

When using custom IDs, you must pass the following values within the iv parameter:

ANA_ID:CUSTOM_ID

ANA_ID represents the Account ID (provided by LiveRamp) whereas CUSTOM_ID represents the custom identifier.

ctint32The type of consent passed to the API.
  • "4" represents a TCF v2 consent string for EU/EEA traffic.
  • "3" represents a CCPA consent string for US traffic (optional).You may use thegpp_sid parameter instead for U.S. users.
gpp_sidstring

The valid corresponding GPP section ID which specifies the GPP consent string type.

They are as follows:
  • "7" represents a US-National string
  • "8" represents a California string
  • "9" represents a Virginia string
  • "10" represents a Colorado string
  • "11" represents a Utah string
  • "12" represents a Connecticut string
  • "13" represents a Florida string
  • "14" represents a Montana string
  • "15" represents a Oregon string
  • "16" represents a Texas string
  • "17" represents a Delaware string
  • "19" represents a Nebraska string
  • "20" represents a New Hampshire string
  • "21" represents a New Jersey string
  • "22" represents a Tennessee string
cvstring

The consent string for TCF v2 and CCPA. See Provide a Valid Consent String for examples.

You may use the gpp parameter instead for US users.

gppstringThe GPP consent string if gpp_sid parameter is set.
atypestringThe ATS implementation method to determine source of envelope call.
  • "1" represents ATS.js
  • "2" represents client-side call to ATS API
  • "3" represents server-side call to ATS API

Server-Side Envelope Retrieval

For serve-side requests, follow the requirements below:

  • In your request, set atype parameter to 3 to identify server-side requests.
  • In the Origin: header of your requests, include a bundle ID tied to your ATS placement prefixed with https:// . For example, https://com.example.app.
  • Include the X-Forwarded-For header with the original client IP address from trusted request infrastructure.
  • Include the Accept: application/json header.

The example below illustrates a server-side call for EU/EEA or UK traffic (ct=4) where TCF consent is required.

curl --get 'https://api.rlcdn.com/api/identity/v2/envelope' \
  --data-urlencode 'pid=<PLACEMENT_ID>' \
  --data-urlencode 'it=4' \
  --data-urlencode 'iv=<NORMALIZED_EMAIL_HASH>' \
  --data-urlencode 'ct=4' \
  --data-urlencode 'cv=<VALID_TCF_CONSENT_STRING>' \
  --data-urlencode 'atype=3' \
  --header 'Origin: https://com.example.app' \
  --header 'X-Forwarded-For: <ORIGINAL_CLIENT_IP>' \
  --header 'Accept: application/json'

keeping the following in mind:

  • Include a bundle ID tied to your ATS placement in the origin header of every request. Prefix your bundle ID with https:// in the origin header (for example, https://com.example.app).
  • For EU users, only call the API with a positive consent string.

See "Call the ATS Envelope API" for more details on each required parameter.

Direct-App Envelope Retrieval (Fallback)

If backend implementation is not possible, you may perform a direct-app requests as a fallback.

  • Set atype=2 (ATS API) on all direct-app requests.
  • Send the same approved Origin header (https://<bundle ID>) and Accept: application/json.
  • Don't send X-Forwarded-For, because the direct connection supplies the client IP.
  • Don't log request URLs, identifiers, or response bodies. These will be handled through the shared lifecycle rules below.
Android Fallback Example (Kotlin/OkHttp)

The builder uses OkHttp 4-style APIs. enqueue keeps network work off Android's UI thread.


import okhttp3.Call
import okhttp3.Callback
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import java.io.IOException

val atsClient = OkHttpClient()

fun makeAtsCall(endpoint: String, placementId: String,
                identifierType: Int, value: String,
                tcfConsent: String): Call {
    val url = endpoint.toHttpUrl().newBuilder()
        .addQueryParameter("pid", placementId)
        .addQueryParameter("it", identifierType.toString())
        .addQueryParameter("iv", value)
        .addQueryParameter("ct", "4")
        .addQueryParameter("cv", tcfConsent)
        .addQueryParameter("atype", "2") // Direct-app ATS API call.
        .build()
    return atsClient.newCall(Request.Builder().url(url).get()
        .header("Origin", "https://com.example.app")
        .header("Accept", "application/json").build())
}

// placementId, normalizedEmailHash and currentConsent are app-provided.
val call = makeAtsCall("https://api.rlcdn.com/api/identity/v2/envelope",
    placementId, 4, normalizedEmailHash, currentConsent)
call.enqueue(object : Callback {
    override fun onFailure(call: Call, error: IOException) {
        // Apply the bounded retry policy; never block ad loading.
    }
    override fun onResponse(call: Call, response: Response) {
        response.use {
            // Check status, parse eligible entries, then commit through
            // the state-token checks in section 1.7. Do not log the body.
        }
    }
})

// Refresh alternative, using the same builder and response handling:
// makeAtsCall("https://api.rlcdn.com/api/identity/v2/envelope/refresh",
//     placementId, 19, currentEnvelope, currentConsent)

iOS Fallback Example (Swift/URLSession)
import Foundation

func makeATSRequest(endpoint: String, placementID: String,
                    identifierType: Int, value: String,
                    tcfConsent: String) -> URLRequest? {
    guard var url = URLComponents(string: endpoint) else { return nil }
    url.queryItems = [
        URLQueryItem(name: "pid", value: placementID),
        URLQueryItem(name: "it", value: String(identifierType)),
        URLQueryItem(name: "iv", value: value),
        URLQueryItem(name: "ct", value: "4"),
        URLQueryItem(name: "cv", value: tcfConsent),
        URLQueryItem(name: "atype", value: "2") // Direct-app ATS API.
    ]
    guard let endpointURL = url.url else { return nil }
    var request = URLRequest(url: endpointURL)
    request.httpMethod = "GET"
    request.setValue("https://com.example.app", forHTTPHeaderField: "Origin")
    request.setValue("application/json", forHTTPHeaderField: "Accept")
    return request
}

// placementID, normalizedEmailHash and currentConsent are app-provided.
if let request = makeATSRequest(
    endpoint: "https://api.rlcdn.com/api/identity/v2/envelope",
    placementID: placementID, identifierType: 4,
    value: normalizedEmailHash, tcfConsent: currentConsent
) {
    URLSession.shared.dataTask(with: request) { data, response, error in
        // Check transport error and HTTP status, parse eligible entries,
        // then commit through section 1.7's state-token checks.
        // Do not log the request URL, identifiers, or response body.
    }.resume()
}

// Refresh alternative, using the same builder and response handling:
// makeATSRequest(
//     endpoint: "https://api.rlcdn.com/api/identity/v2/envelope/refresh",
//     placementID: placementID, identifierType: 19,
//     value: currentEnvelope, tcfConsent: currentConsent)

Responses

For opted-in users, a successful ATS response returns HTTP 200 with one or more envelopes (depending on your integration) in JSON format.

{"envelopes":[{"type":19,"source":"envelopeLiveramp","value":"Aqs3wtOuqIRic78_s4Nqilcr0MGn0cDvKzvpEhSGVjwV8Ci0Jy73B1bkfpv03GwK2uyKbME4kSAtVFn_5sCLWstyHTnEWYurbjLXLpgtf9MfLP1AeDTUQ_0ESnD3x1pr6gYfBOOUH8BPhbfscxdaGUA-_sacPab3nzc05koLhbqrJIQC7JBraEbpOJPDAHp9f44DXIXm","err":null},{"type":25,"source":"pairIds","value":"WyJBeVhiNUF0dmsvVS8xQ1d2ejJuRVk5aFl4T1g3TVFPUTJVQk1BMFdiV1ZFbSJd","err":null}]}

For opted-out users, the call will return a 204 response with no content.

For more information, see "ATS Envelope API Responses".

5. Store Envelopes with Explicit Lifecycle Metadata

Store each envelope as an opaque string, along with metadata that tracks its type, user, expiry, and privacy state. In server-side implementations, your backend handles retrieval, refresh, and timestamps, and your app keeps only the current snapshot to deliver.

  • Protect stored envelopes and backend responses as sensitive identity data, and prevent intermediaries from caching them or serving them across users.
  • If an integration needs envelope types other than the regular ATS envelope, store a separate record per returned envelope type. The Google adapters use only the regular type 19 envelope.

Recommended Lifecycle Fields

ColumnTypeDescription
envelopeStringThe LiveRamp primary ATS envelope (type 19).
envelopeTypeIntegerIdentifies the returned envelope type and required recipient format.
issuedAtLongEpoch milliseconds of the retrieval or refresh that produced this value. Reset it only after a successful call returns a new
value.
expiresAtLongEpoch milliseconds when this value expires. Don't reuse an earlier value's expiry
lastRefreshTimeLongEpoch milliseconds of the last successful retrieval or refresh.
userSessionKeyStringApp-defined identifier for the user or session. Required to prevent one user's envelope from being used for another.
privacyStateVersionLongApp-defined number that gets incremented when the identity or privacy eligibility changes.

Expiry

  • Envelopes expire after 15 days in California, US (1,296,000,000 ms) and 30 days elsewhere (2,592,000,000 ms). Do not infer region solely from the device's language or time zone.

    Do not pass envelopes downstream without determining the expiry or region.

  • Honor an earlier expiry if the API or an integration returns one.
  • Set issuedAt to the request start time (only after a successful response), and calculate expiresAt = issuedAt + TTL.
  • Downloading an envelope doesn't restart its TTL. When your app receives an existing envelope from your backend, keep the backend's timestamps.
📘

Returning Stored Envelopes

For troubleshooting purposes and as required by vendors, such as Prebid.js, you must implement a mock function that returns envelope to the caller from the application.

6. Refresh an Existing Envelope

Refreshing envelopes is an important step to keep the match rate as high as possible for your users. Calling the Refresh Envelope endpoint will reset the envelope expiration to the maximum allowed value.

Refresh existing ATS envelope by calling:

GET https://api.rlcdn.com/api/identity/v2/envelope/refresh

When refreshing an envelope, you must pass the envelope value as the refresh input; not email or phone hash.

When to Refresh an Envelope

We recommend refreshing after 30 minutes (1,800,000 ms) of active use when an ad request needs the envelope. Do not refresh on every ad request. When the user returns and your app resumes, check expiry and refresh timing before making the snapshot eligible. Make sure ads do not wait indefinitely for an identity to be available.

ℹ️

Run only one retrieval or refresh at a time for each user, session, and envelope.

Parameters
ParameterTypeValue
pidint32Your Placement ID.
itint32

The envelope type:

- "19" corresponds to regular ATS envelopes and CAPI identifiers excluding Meta-scoped envelopes.
- "24" corresponds to Meta-scoped envelopes.

ivstringThe envelope value.
ctint32

The type of consent passed to the API.

- "4" represents a TCF v2 consent string for EU/EEA traffic.
- "3" represents a CCPA consent string for U.S. traffic (optional).You may use thegpp_sid parameter instead for U.S. users.

gpp_sidstring

The valid corresponding GPP section ID which specifies the GPP consent string type.

They are as follows:

- "7" represents a US-National string
- "8" represents a California string
- "9" represents a Virginia string
- "10" represents a Colorado string
- "11" represents a Utah string
- "12" represents a Connecticut string
- "13" represents a Florida string
- "14" represents a Montana string
- "15" represents a Oregon string
- "16" represents a Texas string
- "17" represents a Delaware string
- "19" represents a Nebraska string
- "20" represents a New Hampshire string
- "21" represents a New Jersey string
- "22" represents a Tennessee string

cvstring

The consent string for TCF v2 and CCPA. See Provide a Valid Consent String for examples.

You may use the gpp parameter instead for U.S. users.

gppstringThe GPP consent string.
atypestring

The ATS implementation method to determine source of envelope call.

- "1" represents ATS.js
- "2" represents ATS API
- "3" represents server-side implementation

Server-Side Refresh

Use the same atype value and headers as backend envelope retrieval, and send the current privacy
parameters. This example below uses TCF consent for EU/UK traffic. For US traffic, use the GPP parameters instead.

curl --get 'https://api.rlcdn.com/api/identity/v2/envelope/refresh' \
  --data-urlencode 'pid=<PLACEMENT_ID>' \
  --data-urlencode 'it=19' \
  --data-urlencode 'iv=<CURRENT_REGULAR_ATS_ENVELOPE>' \
  --data-urlencode 'ct=4' \
  --data-urlencode 'cv=<CURRENT_VALID_TCF_CONSENT_STRING>' \
  --data-urlencode 'atype=3' \
  --header 'Origin: https://com.example.app' \
  --header 'X-Forwarded-For: <ORIGINAL_CLIENT_IP>' \
  --header 'Accept: application/json'

Direct-App Refresh (Fallback)

If backend request is not possible, use the direct-app envelope retrieval builders with the refresh URL (https://api.rlcdn.com/api/identity/v2/envelope/refresh). Set atype=2 and pass the stored envelope value in iv. The same privacy, expiry, and stale-response checks apply to such calls.

Do not forward an app-supplied IP header for direct-app requests.

Envelope Refresh Response

A successful refresh returns HTTP 200 with fresh envelope to the same identifier. Replace the stale envelope and its metadata in one atomic update. Save only usable values, recalculate their timestamps, and update your partner SDKs and applicable region-specific records.

If you are integrating with other programs that allow multiple envelope types to be returned (i.e. Meta Conversions API), keep separate metadata for each envelope type. Do not extend one type because another refreshed.

Handling HTTP 204 Responses

A 204 response means the API returned no content, which happens when the user has opted out or lacks positive consent, or when the envelope you're refreshing has expired. This consent-related failure should not trigger an automatic retrieval.

When receiving a 204 response:

  • Invalidate the cached identity and clear it from your app and downstream partners, even if the stored expiry is still in the future.
  • Don't reuse the old envelope and don't retry the refresh.
  • Retrieve a new envelope only after you confirm the user's consent.
  • Re-check eligibility when the region, user, placement, or privacy state changes.

Retry Policy

The table lists the recommended retry policy for each error responses and timeouts you may encounter during a refresh. These recommendations are not replacement for rate limits. Adjust them for your traffic and timeout budget.

Before each retry and before saving a result, check if the current user or session should qualify for an envelope. If no eligible envelope remains after retries, load ads without an identity signal.

ResponseWhat to Do
204Do not retry or automatically trigger retrieval. See "Handling HTTP 204 Responses".
400, 401, 403, 451Before retrying, check your request and confirm that the placement is approved and includes the bundle ID in your Origin header and the user's country. Stop using the envelope the user's consent is no longer valid.
429Wait for the Retry-After time to retry. Otherwise use exponential backoff with jitter and a retry limit. If Retry-After is longer than your time budget, defer the retry instead of blocking an ad request.
Timeouts and 5xxUse exponential backoff with jitter. We suggest at most three attempts, waiting about one second and then two seconds, plus jitter.

ATS Mobile SDK Migration Checklist

  • List what the ATS SDK did for your app, such as envelope retrieval, refresh and storage, and each downstream partner it fed.

  • Replace ATS SDK retrieval and refresh with the ATS Envelope API, preferably from your backend.

  • Reconnect each downstream integration to your envelope manager and confirm it receives refreshed values.

  • If you use Google Secure Signals, replace the ATS SDK-provided adapter with your own custom adapter that uses the required LiveRamp class name and remove obsolete SDK setup calls such as
    LRAtsMediationAdapter.configure().

  • Test envelope retrieval, refresh, and each downstream delivery path before you release.


Did this page help you?