Audiences
32min
cookbook upload a csv and match it to the voter file audiences docid\ iocsdy afvbdwt 8lrxng using the audience id returned in step 1, audiences docid\ iocsdy afvbdwt 8lrxng every 5 seconds or so until the uploadedaudiencecsv status value in the audience response is ready for column selection audiences docid\ iocsdy afvbdwt 8lrxng to the voter file using that same audience id (which will be returned in step 3 as well), audiences docid\ iocsdy afvbdwt 8lrxng every 5 seconds or so until the audience's status is active create a lookalike of a matched csv audience follow steps 1 4 in audiences docid\ iocsdy afvbdwt 8lrxng above to match your csv to the voter file using the audience id of your matched audience as the baseaudienceid parameter, audiences docid\ iocsdy afvbdwt 8lrxng from your matched audience using the audience id returned by step 2, audiences docid\ iocsdy afvbdwt 8lrxng every 5 seconds or so until the audience's status is active export an audience to export an audience created via audiences docid\ iocsdy afvbdwt 8lrxng or audiences docid\ iocsdy afvbdwt 8lrxng audiences docid\ iocsdy afvbdwt 8lrxng using the audience id for the audience you'd like to export audiences docid\ iocsdy afvbdwt 8lrxng to the audience until the export's status is no longer in progress if the export's status is now requires payment , audiences docid\ iocsdy afvbdwt 8lrxng by passing in the export id returned in step 1 once the export's status is active , you can use its downloadurl field to download your export csv if you need to download your export again in the future, you can always access it by audiences docid\ iocsdy afvbdwt 8lrxng and then finding your export in the csvexports field on the audience notes api setup to get set up to use our api, reach out to request an api token once you have your token, you'll need to include it in the authorization header of all requests authorization bearer \<token> the base url for our api is https //app indigo engineering/api/v1 customer id customerid is an arbitrary string that should identify each of your customers (this could be a hash or simply an integer id or whatever else you want) the goal here is to separate data by user so that it's easy to tell which records are associated with which of your users however, if you'd like to pass the same customerid for every request, that will work fine as well note that customerid is enforced at the api level and is required for several endpoints, including all the endpoints that create audiences for example, if an audience is created with a customer id of 1 and then /audience is called to retrieve that audience but a customer id of 2 is passed in, no audience will be returned — in other words, no audience with the requested id exists for customer 2 errors to indicate an error, the api will return a json response containing an error key whose value will be a human readable error message in most cases, there will also be an errortype key containing a machine readable error type error responses will typically have a 400 status code or similar (401, 429, 405, etc ) for example { "error" "you've already made this purchase ", "errortype" "purchasableentityalreadypurchased" } endpoints post /upload csv asynchronously upload a csv of people in order to match it to the voter file response is a stub audience request parameters customerid arbitrary string representing a unique customer id this will be associated with the created audience and will need to be passed whenever interacting with that audience url url of the csv example request { "customerid" "123", "url" "https //storage googleapis com/your public bucket/your csv csv" } example response { "id" "1", "createdat" "2025 01 15t20 16 03 410631+00 00", "customerid" "123", "name" null, "status" "pending", "metadata" null, "isarchived" false, "cancreatelookalikefrom" false, "errorinfouserfacing" null, "numlookalikesrequested" null, "lookalikeincludeoriginalaudience" null, "isfilteredfromlookalike" false, "audiencelookalikecreatedfrom" null, "csvexports" \[], "filters" null, "uploadedaudiencecsv" { "id" "1", "createdat" "2025 01 15t20 16 03 406705+00 00", "status" "ready for parsing" }, "uploadedaudiencecsvmatchmetadata" null } post /match uploaded csv asynchronously fill in the audience by matching an uploaded csv to our voter file using our schema and specify which fields are required or optional for our matching algorithm response is the newly created audience note that your audience's uploadedaudiencecsv status must be ready for column selection before calling this endpoint request parameters audienceid the audience id returned from /upload csv customerid arbitrary string representing a unique customer id must be the same as the customer id associated with the audience created in /upload csv audiencename name for audience must be unique by customerid columnselections a json dictionary in which each entry is of the form \[canonical field] { column name \[column name], is required \[true or false] } in each case, canonical field should be one of first name , last name , full name , city , state , zip , phone , dob (date of birth), address , or id column name should be the corresponding column name as it appears in your source csv more details about column selections for api requests, the only constraint on required matching fields is that you must specify at least one field (this differs from the behavior of the matchbook web application, in which the set of required fields must include either a) first name , last name , and at least one other field or b) full name and at least one other field ) if you include full name as a required or optional field, you can't also include first name or last name if you include address , you must make it an optional field (it can't be a required field because matching on address is too unreliable to be used as a strict requirement it can be helpful as an optional matching field, though ) if your source csv has an id column that uniquely identifies each row, you can specify it for tracking purposes (not for the purpose of matching your records to the voter file) if you don't specify an id column, we'll identify the records in your csv using row numbers you may want to use these ids to link your matched audience back to your original csv data note that i f you include id , you must make it a required field example request { 	"audienceid" "1", 	"customerid" "123", 	"audiencename" "some unique audience name", 	"columnselections" { 	 "address" { 	 "column name" "address", 	 "is required" false 	 }, 	 "first name" { 	 "column name" "first name", 	 "is required" true 	 }, 	 "last name" { 	 "column name" "last name", 	 "is required" true 	 }, 	 "state" { 	 "column name" "state", 	 "is required" true 	 }, 	 "zip" { 	 "column name" "zip", 	 "is required" false 	 } 	} } e xample response { "id" "1", "createdat" "2025 01 15t20 13 05 026281+00 00", "customerid" "123", "name" "some unique audience name", "status" "pending", "metadata" null, "isarchived" false, "cancreatelookalikefrom" false, "errorinfouserfacing" null, "numlookalikesrequested" null, "lookalikeincludeoriginalaudience" null, "isfilteredfromlookalike" false, "audiencelookalikecreatedfrom" null, "csvexports" \[], "filters" null, "uploadedaudiencecsv" { "id" "1", "createdat" "2025 01 15t20 13 05 013135+00 00", "status" "active" }, "uploadedaudiencecsvmatchmetadata" null } get /audience retrieve an existing audience request parameters audienceid the audience id customerid (optional) the customer id associated with the audience if the audience has a customer id (i e was created via the api), this will be required to retrieve it if the audience does not have a customer id (i e was created via the app), this isn't required to retrieve it example request { id 1, customerid "123" } example response { "id" "1", "createdat" "2025 01 15t20 13 05 026281+00 00", "customerid" "123", "name" "some unique audience name", "status" "active", "metadata" { "size" 58015, "gender f" 28613, "gender m" 28394, "num phones" 23219, "party dem" 19474, "party ind" 24750, "party rep" 13791, "race aapi" 6404, "race none" 4749, "race black" 5995, "race white" 28536, "gender none" 1008, "race latino" 11811, "age group 55+" 12733, "age group 18 34" 29053, "age group 35 54" 15211, "age group alt 65+" 7171, "age group alt 18 24" 11803, "race native american" 520 }, "isarchived" false, "cancreatelookalikefrom" true, "errorinfouserfacing" null, "numlookalikesrequested" null, "lookalikeincludeoriginalaudience" null, "isfilteredfromlookalike" false, "audiencelookalikecreatedfrom" null, "csvexports" \[], "filters" null, "uploadedaudiencecsv" { "id" "1", "createdat" "2025 01 15t20 13 05 013135+00 00", "status" "active" }, "uploadedaudiencecsvmatchmetadata" { "nummatches" 58333, "numuniquematches" 58015, "columnmatchresults" \[ { "column" "zip", "percentofmatches" 0 9867999245709975, "percentmissing" 0 0 }, { "column" "state", "percentofmatches" 1 0, "percentmissing" 0 0 }, { "column" "address", "percentofmatches" 0 9870913548077418, "percentmissing" 0 0 }, { "column" "last name", "percentofmatches" 1 0, "percentmissing" 0 0 }, { "column" "first name", "percentofmatches" 1 0, "percentmissing" 0 0 } ] } } post /create preview csv export s ynchronously create a preview csv export this will include the purchase price for the export response is the export record, with information about the associated audience record nested under the audience key request parameters audienceid the audience id customerid (optional) the customer id associated with the audience if the audience has a customer id (i e was created via the api), this is required if the audience does not have a customer id (i e was created via the app), this isn't required optionalfieldtypes a list of paid contact info field types to be included in the export in addition to the standard fields that are provided free of charge the current options are phone , address , vote history , issue scores , media scores , support scores , turnout scores , and lookalike scores the response shows the cost (in cents) of the proposed export and includes a breakdown of how that cost was computed example request { 	"audienceid" 1, 	"customerid" "123", 	"optionalfieldtypes" \[ 	 "phone", 	] } example response { "id" "1", "purchasecostbreakdown" { "phone" { "price per record" 6, "count total available" 23219, "count already paid" 0, "count requiring payment" 23219 }, }, "size" 58015, "totalcost" 139314, "audience" { "id" "1", "customerid" "123", "metadata" { "size" 58015, "gender f" 28613, "gender m" 28394, "num phones" 23219, "party dem" 19474, "party ind" 24750, "party rep" 13791, "race aapi" 6404, "race none" 4749, "race black" 5995, "race white" 28536, "gender none" 1008, "race latino" 11811, "age group 55+" 12733, "age group 18 34" 29053, "age group 35 54" 15211, "age group alt 65+" 7171, "age group alt 18 24" 11803, "race native american" 520 } } } post /purchase csv export synchronously purchase a csv export after creating a preview via /create preview csv export response is the export record, with a couple fields of information about the associated audience record nested under the audience key note that if the export has a cost associated with it, your organization will be invoiced for the purchase request parameters exportid the export id from /create preview csv export customerid (optional) the customer id associated with the audience / export if the audience has a customer id (i e was created via the api), this will be required if the audience does not have a customer id (i e was created via the app), this isn't required example request { "exportid" "1", "customerid" "123" } example response { "id" "1", "createdat" "2025 01 22t18 43 38 342670+00 00", "downloadurl" "https //storage googleapis com/matchbook exports/ ", "purchasecostbreakdown" { "phone" { "price per record" 6, "count total available" 23219, "count already paid" 0, "count requiring payment" 23219 } }, "status" "active", "totalcost" 139314, "audience" { "id" "1", "customerid" "123", "metadata" { "size" 58015, "gender f" 28613, "gender m" 28394, "num phones" 23219, "party dem" 19474, "party ind" 24750, "party rep" 13791, "race aapi" 6404, "race none" 4749, "race black" 5995, "race white" 28536, "gender none" 1008, "race latino" 11811, "age group 55+" 12733, "age group 18 34" 29053, "age group 35 54" 15211, "age group alt 65+" 7171, "age group alt 18 24" 11803, "race native american" 520 } } } post /create lookalike audience asynchronously create a lookalike audience based on an existing matched audience to be eligible for lookalike expansion, an audience must be based on matching at least 1,000 people to the voter file from an uploaded csv response is the audience record request parameters baseaudienceid id of a matched audience to use as the base for the lookalike customerid c ustomer id to use for the new audience if the base audience does not have a customer id (i e it was created via the app), that is ok — the base audience only needs to match the passed in customer id if it has one size desired size of your lookalike audience as an integer audiencename name for the new lookalike audience must be unique by customerid includeoriginalaudience (optional) boolean, whether to include the original audience's members in the lookalike filters (optional) a json dictionary containing filters to be applied, in which entries are of the form specified below "filters" { // integer "ageend" 70, // boolean "ageincludeunknown" true, // integer "agestart" 24, // string cell is only valid option currently "contactinfo" "cell", // list of strings, all possible options listed below "genders" \[ "none", "m", "f" ], // boolean "hasdonorhistory" true, // list of strings, all possible options listed below "races" \[ "black", "latino", "native american", "white", "none", "aapi" ], // date (string) formatted like 'yyyy mm dd' "registrationdateend" "2025 12 31", // date (string) formatted like 'yyyy mm dd' "registrationdatestart" "1900 01 01", // see "geographic filters" pages (links below) for details "congressionaldistricts" null, "stateleglowerdistricts" null, "statelegupperdistricts" null, "counties" null, // list of strings, all two digit state codes including dc "states" \["ny"], // five digit zip code as string if present, `distancefromzip` must also be present "zip" "11215" // integer, in miles (can be 0) if present, `zip` must also be present "distancefromzip" 3, } see counties docid 4av 7 40kr95pixgj7t9h , congressional districts docid\ ixcvra3bersrg prmq4ir , upper state legislative districts docid 61wktlkm0hwxodajq3cql , and lower state legislative districts docid\ gjgzg mjrcfzxcwn6 qq1 for details on the possible values for those fields note that geographic filters are applied with a conjunction, meaning that only voters who match all of these geographic filters will be included in your audience e xample request { "audiencename" "lookalike of some unique audience name", "baseaudienceid" 1, "size" 2000, "customerid" "123", "filters" { "states" \[ "co", "ca" ] } } e xample response { "id" "6", "createdat" "2025 01 22t17 17 17 715679+00 00", "customerid" "123", "name" "lookalike of some unique audience name", "status" "pending", "metadata" null, "isarchived" false, "cancreatelookalikefrom" false, "errorinfouserfacing" null, "numlookalikesrequested" 2000, "lookalikeincludeoriginalaudience" null, "isfilteredfromlookalike" false, "audiencelookalikecreatedfrom" { "id" "1" }, "csvexports" \[], "filters" { "id" "10", "createdat" "2025 01 22t18 22 57 710604+00 00", "states" \[ "co", "ca" ], "counties" null, "congressionaldistricts" null, "stateleglowerdistricts" null, "statelegupperdistricts" null, "zip" null, "distancefromzip" null, "agestart" null, "ageend" null, "ageincludeunknown" null, "genders" null, "races" null, "registrationdatestart" null, "registrationdateend" null, "hasdonorhistory" null, "contactinfo" null, "sortfield" null, "sortasc" null, "limit" null }, "uploadedaudiencecsv" null, "uploadedaudiencecsvmatchmetadata" null } get /audiences retrieve a list of audiences for your organization request parameters customerid (optional) only return audiences with this customerid if no customer id is passed, this will return all audiences example request { customerid "123" } example response \[ { "id" "1", "createdat" "2025 01 15t20 13 05 026281+00 00", "customerid" "123", "name" "some unique audience name", "status" "active", "metadata" { "size" 58015, "gender f" 28613, "gender m" 28394, "num phones" 23219, "party dem" 19474, "party ind" 24750, "party rep" 13791, "race aapi" 6404, "race none" 4749, "race black" 5995, "race white" 28536, "gender none" 1008, "race latino" 11811, "age group 55+" 12733, "age group 18 34" 29053, "age group 35 54" 15211, "age group alt 65+" 7171, "age group alt 18 24" 11803, "race native american" 520 }, "isarchived" false, "cancreatelookalikefrom" true, "errorinfouserfacing" null, "numlookalikesrequested" null, "lookalikeincludeoriginalaudience" null, "isfilteredfromlookalike" false, "audiencelookalikecreatedfrom" null, "csvexports" \[], "filters" null, "uploadedaudiencecsv" { "id" "1", "createdat" "2025 01 15t20 13 05 013135+00 00", "status" "active" }, "uploadedaudiencecsvmatchmetadata" { "nummatches" 58333, "numuniquematches" 58015, "columnmatchresults" \[ { "column" "zip", "percentofmatches" 0 9867999245709975, "percentmissing" 0 0 }, { "column" "state", "percentofmatches" 1 0, "percentmissing" 0 0 }, { "column" "address", "percentofmatches" 0 9870913548077418, "percentmissing" 0 0 }, { "column" "last name", "percentofmatches" 1 0, "percentmissing" 0 0 }, { "column" "first name", "percentofmatches" 1 0, "percentmissing" 0 0 } ] } }, { "id" "6", "createdat" "2025 01 22t17 17 17 715679+00 00", "customerid" "123", "name" "lookalike of some unique audience name", "status" "active", "metadata" null, "isarchived" false, "cancreatelookalikefrom" false, "errorinfouserfacing" null, "numlookalikesrequested" 1000, "lookalikeincludeoriginalaudience" null, "isfilteredfromlookalike" false, "audiencelookalikecreatedfrom" { "id" "1" }, "csvexports" \[], "filters" { "id" "10", "createdat" "2025 01 22t18 22 57 710604+00 00", "states" \["co", "ca"], "counties" null, "congressionaldistricts" null, "stateleglowerdistricts" null, "statelegupperdistricts" null, "zip" null, "distancefromzip" null, "agestart" null, "ageend" null, "ageincludeunknown" null, "genders" null, "races" null, "registrationdatestart" null, "registrationdateend" null, "hasdonorhistory" null, "contactinfo" null, "sortfield" null, "sortasc" null, "limit" null }, "uploadedaudiencecsv" null, "uploadedaudiencecsvmatchmetadata" null } ]