Skip to content
tezvyn:
Menu

Programmatically create an ad via a marketing API

Source: interviewEasyHow cards are made

Summary

the ad-object hierarchy.

Key points

authenticate, create a campaign with an objective, an ad set with budget and targeting, a creative with the copy, then the ad linking them.

Watch out for

thinking one call with ad copy creates a live ad.

What's really being asked

It checks whether you understand that ad platforms expose a nested object hierarchy and what each level requires, rather than offering a single create-ad call that does everything.

The full answer

First authenticate, typically an OAuth access token scoped to an ad account you have permission to manage. Then work down the hierarchy. Create a Campaign, which sets the high-level objective such as traffic, conversions, or lead generation. Create an Ad Set under that campaign, which carries the budget and bidding, the schedule with a start and end, the optimization goal, and the audience targeting covering demographics, interests, and placements. Create an Ad Creative, the object holding the actual copy: the primary text, headline, description, the image or video asset, and the destination link or call-to-action. Finally create the Ad itself, which links a specific creative to a specific ad set and sets its status, often paused for review before going live. Each object returns an ID consumed by the next call.

The mistakes people make

Believing one POST with the ad text publishes a live ad. Forgetting authentication and ad-account scoping entirely. Putting targeting or budget on the creative instead of the ad set. Ignoring that platforms review ads for policy before they ever serve to users.

What usually comes next

Where does targeting versus budget actually live in the hierarchy. How do you upload an image asset before referencing it. How do you keep an ad paused until approval. How do you handle API rate limits and partial-failure errors mid-sequence.

A concrete example

To launch a startup promotion, your app gets an access token, creates a campaign with objective LINK_CLICKS, creates an ad set with a daily budget and an audience of founders aged twenty-five to forty-five, uploads the image and creates a creative with the headline and body copy, then creates the ad referencing that creative and ad set in paused status awaiting review before it begins serving impressions.

Interview question

In a Facebook-style marketing API, which object typically holds the audience targeting and budget rather than the ad copy?

  • a.The ad setCorrect
  • b.The access token
  • c.The ad creative
  • d.The campaign objective alone
Why?

Targeting, budget, schedule, and bidding live on the ad set, while the creative holds the copy and assets. Placing budget on the creative confuses the platform's nested object hierarchy.

Just read this? Test yourself on what you have been reading.

Read the original → developers.facebook.com

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles