-
You'll need to request your specific access token from the CreativeX team. This is a unique token which will allow you to create pre-flights for your organization using the Content API. This is required in order to make any calls to any of our endpoints.
-
Before creating preflights, you'll need to upload assets (images / videos) to our S3 data store. To do this, you can retrieve a pre-signed url from our API, and then upload your image or video to that url:
require 'net/http'
require 'rest_client'
require 'uri'
require 'json'
def access_token
# Insert your access token here
end
def base_url
'https://api.creativex.com/api/v3'
end
def url(path, params)
"#{base_url}?#{URI.encode_www_form(params)}"
end
def presigned_url
params = { access_token: access_token }
path = '/presigned_url'
uri = URI(url(path, params))
res = Net::HTTP.get_response(uri)
URI.parse(JSON.parse(res.body))
end
You can then upload a locally stored image or video to the url returned from above:
def local_image_path
'path/image.jpg'
end
def upload_image_to_presigned_url
RestClient.put(presigned_url.to_s, File.read(local_image_path), :content_type => 'image/jpg')
end
Once we have access to these assets, you're ready to start creating preflights!
def create_preflight
params = { access_token: access_token }
body = {
creatives: [{ source_url: presigned_url, external_label: 'Optional identifier'}],
name: 'MyPreflight',
brand: 'Acme',
market: 'United Kingdom',
channel: 'facebook_paid',
publisher: 'facebook',
placement: 'feed'
}
path = '/preflights'
req = Net::HTTP::Post.new(url(path, params))
res = Net::HTTP.start(base_url.hostname, base_url.port) do |http|
http.request(req)
end
JSON.parse(res.body)
end
You've now created your first preflight! You can now check the status of a preflight through the GET /preflight/:id
route using the request_id
you get in the response to that initial POST
request:
def get_preflight_status
preflight_id = 'MyPreflightId'
params = { access_token: access_token }
path = "/preflights/#{preflight_id}"
uri = URI(url(path, params))
res = Net::HTTP.get_response(uri)
JSON.parse(res.body)
end
Once the preflight has completed processing, the response from GET /preflights/:id
should look something like:
{
"request_id": 21490,
"created_at": "2024-08-05T08:50:31.913Z",
"status": "completed",
"name": "MyPreflight",
"brand": "Acme",
"market": "United Kingdom",
"channel": "facebook_paid",
"creatives": [
{
"post_id": 1234,
"url": "https://s3.amazonaws.com/picassolabs-assets/original/file.mp4",
"external_label": "Optional identifier",
"scorecard_url": "http://www.creativex.com/audit/scorecards/1234?pretest=true",
"scores": [
{
"name": "Creative Quality",
"value": 0.8,
"status": "status",
"creative_quality_tier": "Excellent",
"guidelines": [
{
"name": "Humanise",
"weight": "20.0%",
"passed": true
},
{
"name": "Mention",
"weight": "0.0%",
"passed": true
},
{
"name": "Branding: Brand Name",
"weight": "20.0%",
"passed": true
},
{
"name": "Product",
"weight": "20.0%",
"passed": false
},
{
"name": "Optimised for Sound Off",
"weight": "20.0%",
"passed": true
},
{
"name": "Simple Message",
"weight": "20.0%",
"passed": true
}
]
}
]
}
]
}