https://www.growthbook.io/ logo
p

plain-egg-64821

07/08/2022, 11:16 PM
Is there a way to create experiments and attribute targets in growthbook via an API? https://docs.growthbook.io/app/features#targeting-attributes (I'm a total noob doing some feasibility research)
I'm mapping out how to build a plugin for strapi where users dupe content and add attributes or some kind of link to rules in growthbook
Would this be via the feature controller? https://github.com/growthbook/growthbook/blob/main/packages/back-end/src/controllers/features.ts I don't see a mention of the property. But there's a spread in the middle of the interface.
b

busy-horse-73824

07/09/2022, 8:43 AM
I believe at the moment there's no API. Might be possible to write into the DB if you're self hosting, but no idea how complex the structure is
f

future-candle-10380

07/09/2022, 1:05 PM
Growthbook does have an API that is consumed by fornt-end. You can see definition of POST experiment here: https://github.com/growthbook/growthbook/blob/main/packages/back-end/src/controllers/experiments.ts#L379 Although there is no support for external API auth keys and current ones have only 1day expiration time so you would have to probable create a dummy user and that credentials to reauthenticate everyday. A bit clunky but definitely possible
👌 1
p

plain-egg-64821

07/09/2022, 1:21 PM
Ok so could I create an experiment and add tracking attributes via the API?
The use case is remotely creating ab tests from a CMS.
f

future-candle-10380

07/09/2022, 1:43 PM
yes, of course you can. Make sure you send the data in a correct format: https://github.com/growthbook/growthbook/blob/main/packages/back-end/src/controllers/experiments.ts#L428 You can also debug API request sent when creating an experiment manually on the frontend to help you with sending data in a correct format.
👍 1
f

faint-van-19888

09/07/2022, 7:34 AM
@future-candle-10380 @busy-horse-73824 coming from the future, I'd say an official write API would be a great addition. Any solid plans to make that happen?
b

busy-horse-73824

09/09/2022, 4:18 PM
We don't work at Growthbook 🙂 might be worth posting a new thread
3 Views