To set up your Meta/Facebook connection, you will need an access token from a system user. Below, you will find a step-by-step guide to retrieve this access token. Once you have an access token, you can easily add the Meta connection in your advertiser settings.
Add Access Token to Pexi
Go to your advertiser and click 'Settings'.
Within the settings page, go to the Connections card and click 'Add connection'. A modal will appear, asking you to fill in the following details:
Name: A name for the Meta connection. This is an optional field to help you recognize the connection.
Type: The type should be set to 'Meta' for this connection.
Access Token: After selecting the type, you can enter the access token you’ve retrieved by following the steps below.
Click 'Create connection' to add the connection to your advertiser.
Click 'Create connection' to add the connection to your advertiser.
How to Create a Facebook System User
Creating a Facebook System User is necessary when you want to automate tasks or access your Facebook assets (like Ads, Pages, or Pixels) via an API. A system user represents servers or applications (instead of individuals) and is mainly used in conjunction with the Facebook Marketing API.
Here is a step-by-step guide on how to create a Facebook System User:
Prerequisites:
Facebook Business Manager Account: You must have admin access to a Facebook Business Manager account. If you don’t have one, you can create it at business.facebook.com.
Admin Privileges: You must have admin rights to create system users and manage assets.
Ensure you are in the correct Business Manager account by checking the account name in the top-left corner.
Step 2: Navigate to Business Settings
On the left-hand side, click on the hamburger menu (three horizontal lines).
Under the "Accounts" section, select Business Settings.
This will take you to the business settings dashboard, where you manage users, assets, and integrations.
Step 3: Create a System User
In the Business Settings panel, scroll down to the "Users" section and click on System Users.
Click the Add button.
In the popup, you’ll need to provide a name for your system user (e.g., “Marketing API System User”).
Choose the Role:
Admin: Full control over assigned assets.
Employee: Limited access to assets.
After filling in the required information, click Create System User.
Step 4: Assign Assets to the System User
Once your system user is created, you need to assign assets (like ad accounts, pages, or pixels) to this user.
Click on the Assign Assets button next to the newly created system user.
Select the assets that this system user should have access to (e.g., an ad account, page, etc.).
Choose the type of access (e.g., full control, partial access).
Click Save Changes to apply permissions.
Step 5: Generate an Access Token
Now that your system user is created, you need to generate an access token so the system user can access Facebook's APIs.
While still in the System Users section, click on your system user's name.
Under the “Assigned Assets” section, look for Generate New Token and click it.
In the popup, select the assets that the token will have access to (e.g., Ad Account, Pages).
Choose the permissions needed (e.g., ads_read, ads_management, pages_read_engagement).
Click Generate Token.
Save this token securely—this is what your application or server will use to authenticate and make API calls.
Step 6: Implement the Access Token in Your Application
You will use the generated access token in your application to make API requests to Facebook. This access token allows your app or server to perform tasks (like creating ads, retrieving insights, etc.) on behalf of the system user.
You can use the token in API calls like:
curl -X GET "https://graph.facebook.com/v14.0/<AD_ACCOUNT_ID>/ads" \
-d "access_token=<YOUR_ACCESS_TOKEN>"
Important Notes:
Token Expiration: Make sure you monitor token expiration. Some tokens are long-lived, but you need to handle token refresh processes in your application.
Permissions: Only request the permissions that are necessary for your app. Excessive permissions can lead to your app being flagged by Facebook.
Security: Keep your access tokens and credentials secure to prevent unauthorized access to your Facebook assets.
By following these steps, you’ll have successfully created a system user in Facebook Business Manager and will be able to access your Facebook assets programmatically through the Marketing API.