Each authenticated profile includes an optional demographic which can be used to increase the accuracy of any analysis. This data is not collected automatically. Your app can choose to GET or POST this demographic via the Sahha API.


Data Format

All values are optional

Leave out any value you don't have.

gender : String

Gender must be a valid String from this list:

  • 'Male'
  • 'Female'
  • 'Gender Diverse'

Sahha ignores any other value. Use the values exactly as shown: Android SDK versions up to 1.4.0 also ignore any other letter case, such as 'male'.

birthDate : String

Birth Date must be a String in the format 'YYYY-MM-DD'. For example, '1990-05-20'. Send the date only, without a time.

The Sahha API also accepts age, but the SDKs don't send it.


Using the API for Demographics

You can GET or POST demographic info via the API using this model.

Which fields each SDK sends

Every SDK and plugin sends only gender and birthDate. The Android SDK's SahhaDemographic also has age, country and nine other properties, but the SDK doesn't send them, so they're never stored. The plugins ignore any other keys you pass.

SahhaDemographic.swift
Swift
// All values are optional

public struct SahhaDemographic: Codable, Equatable, Sendable {
    public var gender: String? // "Male", "Female" or "Gender Diverse"
    public var birthDate: String? // must be in format "YYYY-MM-DD", i.e. "1990-05-20"
}

POST

An example POST of demographic info via the SDK.

MyApp.swift
Swift
let demographic = SahhaDemographic(
    gender: "Female",
    birthDate: "1990-05-20"
)

Sahha.postDemographic(demographic) { error, success in
    if let error = error {
        print(error)
    }
    print(success)
}

GET

An example GET of demographic info via the SDK.

MyApp.swift
Swift
Sahha.getDemographic() { error, demographic in
    if let error = error {
        print(error)
    }
    if let demographic = demographic {
        print(demographic)
    }
}
Docs