Documentation / API / campaigns_saved_opportunity_add
campaigns_saved_opportunity_add
POSThttps://api.oppalerts.com/v1/campaigns/saved_opportunity_add
Adds one saved opportunity to a campaign: a saved search that is counted every day.
What it does
The tool adds one saved opportunity to a campaign. A saved opportunity is a saved search. The daily count job counts it on the News Index and the Prospect Index every day, and the daily opportunities email reports it.
A saved opportunity uses no type, one opportunity type, one content type, or one of the 6 brand searches. On the free plan, a campaign can have a maximum of 7 active saved opportunities, and each active brand search counts against this limit. Saved opportunities can be added after the campaign is finalized.
Nothing is counted during the call: the counts are calculated on the next daily run. The response contains the new saved opportunity and its id. In the web app, it shows on the Opportunities tab of Edit Campaign.
Who May Call It
- The account owner, an account editor, or a campaign editor of this campaign. An account viewer or a campaign viewer gets the error
no_access. - The token needs the scope
api:write, andapi:readas every API route does. Withoutapi:write, the call gets the errorforbidden. Authentication says which tokens have it.
Authentication
Send your token in the Authorization: Bearer header. The API overview explains how to get a token. The API also accepts the same call at POST /v1/campaigns_saved_opportunity_add.
Parameters
campaignint, required, 1 to 4294967295- The campaign id, from campaigns_list. It must be a campaign of your account.
labelstring, required, at most 255 characters- Required. The name of the saved opportunity, at most 255 characters. It must be different from the names of the other saved opportunities of the campaign.
searchstring, required- Required. What the saved opportunity finds. no_type finds pages by the vector, the words, or both, with no type. opportunity_type finds the pages of the opportunity type in opportunity_type, and content_type the pages of the content type in content_type, at or above type_score_min. The other 6 values are the brand searches: they read the organizations of the campaign, and they take only the PR, PRoT, and link fields. Values:
no_type,opportunity_type,content_type,brand_links,brand_mentions,unlinked_brand_mentions,brand_link_gap,competitor_links, andcompetitor_mentions. opportunity_typestring, required for some calls, at most 120 characters- Required for search opportunity_type, and refused for every other search. An opportunity type as <group>/<type>, for example advertising/newsletter-ads, from types_opportunity_types, at most 120 characters.
content_typestring, required for some calls, at most 120 characters- Required for search content_type, and refused for every other search. A content type, for example blogs, from types_content_types, at most 120 characters.
type_score_minint, required for some calls, 1 to 100- Required for search opportunity_type and content_type, and refused for every other search. The least type score a page must have, a whole number from 1 to 100. 0 is refused. Each page has one score for each type, from 0 to 100.
similarity_targetstring, required for some calls- Required for search no_type, opportunity_type, and content_type, and refused for a brand search: the vector the pages must be semantically similar to. none is no vector: the words alone find the pages. campaign is the market description of the campaign. similarity_text is the text in similarity_text. Values:
none,campaign, andsimilarity_text. similarity_textstring, required for some calls, at most 20000 characters- Required when similarity_target is similarity_text, and refused for another similarity_target or a brand search: the text the pages must be semantically similar to, at most 1,000 words and at most 20,000 characters. A text that is too long is refused, never cut. A text of only spaces is refused.
similarity_score_minint, required for some calls, 1 to 100- Required when similarity_target is campaign or similarity_text, and refused when it is none or for a brand search: the least similarity in percent, 1 to 100. It applies on both indexes.
title_querystring, optional, at most 500 characters- Optional, and refused for a brand search. Words the title must have, at most 500 characters. It takes these search operators: AND, OR, MAYBE, NEAR/N, and NOTNEAR/N in capitals, the Negation operator (-), the Phrase search operator, the Proximity search operator (~N), the Exact form modifier (=), the IDF boost modifier (^N), the Wildcard operator (* at the end of a word), and Grouping with parentheses (one level). A wrong use is refused with a sentence that names the field. The full list is in the documentation: https://oppalerts.com/docs/the-data/advanced-search-operators. At most 20 words or phrases: a text with more is refused, and nothing is cut. A text with no word or phrase, such as only OR or only spaces, is refused. Leave it out for no title words.
body_querystring, optional, at most 500 characters- Optional, and refused for a brand search. Words the body must have, at most 500 characters, with the rules of title_query. Leave it out for no body words.
title_body_joinstring, required for some calls- Required when both title_query and body_query are sent, and refused otherwise. and: a page must match both. or: a page must match one of them. Values:
andandor. pr_domain_minint, optional, 0 to 100- Optional. Keep the pages whose domain PageRank is at least this value, a whole number from 0 to 100. 0 applies no minimum. Not sent: no minimum. Refused when it is above pr_domain_max.
pr_domain_maxint, optional, 1 to 100- Optional. Keep the pages whose domain PageRank is at most this value, a whole number from 1 to 100. 100 applies no maximum, the same as not sent: a page with no domain PageRank stays in the results. 0 is refused. Not sent: no maximum.
pr_host_minint, optional, 0 to 100- Optional. Keep the pages whose host PageRank is at least this value, a whole number from 0 to 100. 0 applies no minimum. Not sent: no minimum. Refused when it is above pr_host_max.
pr_host_maxint, optional, 1 to 100- Optional. Keep the pages whose host PageRank is at most this value, a whole number from 1 to 100. 100 applies no maximum, the same as not sent: a page with no host PageRank stays in the results. 0 is refused. Not sent: no maximum.
prot_domain_minint, optional, 0 to 1000000- Optional. Keep the pages whose domain PRoT is at least this value, a whole number from 0 to 1000000. PRoT (PageRank over Time) is the sum of the monthly PageRank values of the domain. 0 applies no minimum. Not sent: no minimum. Refused when it is above prot_domain_max.
prot_domain_maxint, optional, 1 to 1000000- Optional. Keep the pages whose domain PRoT is at most this value, a whole number from 1 to 1000000. PRoT (PageRank over Time) is the sum of the monthly PageRank values of the domain. 0 is refused. Not sent: no maximum.
prot_host_minint, optional, 0 to 1000000- Optional. Keep the pages whose host PRoT is at least this value, a whole number from 0 to 1000000. PRoT (PageRank over Time) is the sum of the monthly PageRank values of the host. 0 applies no minimum. Not sent: no minimum. Refused when it is above prot_host_max.
prot_host_maxint, optional, 1 to 1000000- Optional. Keep the pages whose host PRoT is at most this value, a whole number from 1 to 1000000. PRoT (PageRank over Time) is the sum of the monthly PageRank values of the host. 0 is refused. Not sent: no maximum.
link_counts_minobject, optional- Optional. The least number of outbound links of each link type in each page section, the shape that prospects_search takes: {"article"|"nav"|"comments": {"follow"|"nofollow"|"sponsored"|"ugc": n}}. A page must have at least n links of that type in that section. Leave it out, or leave out a section or a link type, for no minimum.
link_counts_min.articleobject, optional- Optional. The article section of the page.
link_counts_min.article.followint, optional, 0 to 4294967295- Optional. The least number of follow links in that section, a whole number of 0 or more. 0 applies no minimum.
link_counts_min.article.nofollowint, optional, 0 to 4294967295- Optional. The least number of nofollow links in that section, a whole number of 0 or more. 0 applies no minimum.
link_counts_min.article.sponsoredint, optional, 0 to 4294967295- Optional. The least number of rel=sponsored links in that section, a whole number of 0 or more. 0 applies no minimum.
link_counts_min.article.ugcint, optional, 0 to 4294967295- Optional. The least number of rel=ugc links in that section, a whole number of 0 or more. 0 applies no minimum.
link_counts_min.navobject, optional- Optional. The navigation section of the page.
link_counts_min.nav.followint, optional, 0 to 4294967295- Optional. The least number of follow links in that section, a whole number of 0 or more. 0 applies no minimum.
link_counts_min.nav.nofollowint, optional, 0 to 4294967295- Optional. The least number of nofollow links in that section, a whole number of 0 or more. 0 applies no minimum.
link_counts_min.nav.sponsoredint, optional, 0 to 4294967295- Optional. The least number of rel=sponsored links in that section, a whole number of 0 or more. 0 applies no minimum.
link_counts_min.nav.ugcint, optional, 0 to 4294967295- Optional. The least number of rel=ugc links in that section, a whole number of 0 or more. 0 applies no minimum.
link_counts_min.commentsobject, optional- Optional. The comments section of the page, where visitors add content.
link_counts_min.comments.followint, optional, 0 to 4294967295- Optional. The least number of follow links in that section, a whole number of 0 or more. 0 applies no minimum.
link_counts_min.comments.nofollowint, optional, 0 to 4294967295- Optional. The least number of nofollow links in that section, a whole number of 0 or more. 0 applies no minimum.
link_counts_min.comments.sponsoredint, optional, 0 to 4294967295- Optional. The least number of rel=sponsored links in that section, a whole number of 0 or more. 0 applies no minimum.
link_counts_min.comments.ugcint, optional, 0 to 4294967295- Optional. The least number of rel=ugc links in that section, a whole number of 0 or more. 0 applies no minimum.
Rules
labelandsearchare required. The label must be different from the labels of the other saved opportunities of the campaign.- For
searchno_type,opportunity_type, andcontent_type:similarity_targetis required. similarity_score_minis required with a vector, that is whensimilarity_targetiscampaignorsimilarity_text. It is refused whensimilarity_targetisnone.similarity_textis required whensimilarity_targetissimilarity_text, and refused for another value.opportunity_typeandtype_score_minare required forsearchopportunity_type.content_typeandtype_score_minare required forsearchcontent_type. Each one is refused for every other search.- A vector or words are required: a call with
similarity_targetnone, notitle_query, and nobody_queryis refused withnothing_to_search. title_body_joinis required when bothtitle_queryandbody_queryare sent, and refused otherwise.- A brand search (
brand_links,brand_mentions,unlinked_brand_mentions,brand_link_gap,competitor_links, orcompetitor_mentions) takes only the PR, PRoT, and link fields. It refusestitle_query,body_query,title_body_join, and every vector field. - The PR, PRoT, and link fields are optional. A field that you leave out is no minimum or no maximum. A minimum above its maximum is refused with
min_above_max. - A PR maximum takes 1 to 100, and a PRoT maximum takes 1 to 1,000,000. 0 is refused with
rank_out_of_range. A PR maximum of 100 applies no maximum, the same as not sent. type_score_mintakes 1 to 100. 0 is refused.- A similarity text that is too long is refused, never cut.
title_queryandbody_querytake the search operators of Advanced Search Operators. A query with a formatting error is refused withquery_operator, and it is not saved. The sentence names the field, says that the query has a formatting error, and says what the error is.
Strict Rules
- A field that is not in the list above is refused. The answer is HTTP 400 with the error code
bad_param. The error names the field: "<field> is not a field of this tool." - A bad value is refused, and the error names the field. A bad value is a value of the wrong type, a number with a fraction for a whole-number field, a value out of its range, a value that is not in its list, or an empty text, list, or object. A required field that you do not send is refused too. To send no value for an optional field, leave the field out. No field has a default value, and the tool never changes a value that you send.
- An error about the format of a call, such as a refused field, names the field. Its message ends with one sentence: "Read the documentation at https://oppalerts.com/docs for the correct format." Every other error, such as
forbiddenbelow, has only its own sentence.
Response fields
The response contains the saved opportunity, in the same format that campaigns_saved_opportunities returns for each saved opportunity.
opportunity.idint- The id of the saved opportunity. news_opportunities and prospects_opportunities take it as
opportunity. opportunity.labelstring- The name of the saved opportunity.
opportunity.statestring- The state of the saved opportunity. The example shows
active. opportunity.searchstring- What the saved opportunity finds:
no_type,opportunity_type,content_type, or one of the 6 brand searchesbrand_links,brand_mentions,unlinked_brand_mentions,brand_link_gap,competitor_links, andcompetitor_mentions. opportunity.opportunity_typestring- The opportunity type as
<group>/<type>, forsearchopportunity_type. Empty for another search. opportunity.content_typestring- The content type, for
searchcontent_type. Empty for another search. opportunity.filtersobject- The numeric fields of the saved opportunity. A number that is not set is not in
filters. opportunity.filters.type_score_minint, optional- The minimum type score, 0 to 100.
opportunity.filters.similarity_score_minint, optional- The minimum similarity in percent, 1 to 100.
opportunity.filters.pr_domain_minint, optional- The minimum domain PageRank, 0 to 100.
opportunity.filters.pr_domain_maxint, optional- The maximum domain PageRank, 0 to 100.
opportunity.filters.pr_host_minint, optional- The minimum host PageRank, 0 to 100.
opportunity.filters.pr_host_maxint, optional- The maximum host PageRank, 0 to 100.
opportunity.filters.prot_domain_minint, optional- The minimum domain PRoT (PageRank over Time), 0 to 1000000.
opportunity.filters.prot_domain_maxint, optional- The maximum domain PRoT, 0 to 1000000.
opportunity.filters.prot_host_minint, optional- The minimum host PRoT, 0 to 1000000.
opportunity.filters.prot_host_maxint, optional- The maximum host PRoT, 0 to 1000000.
opportunity.filters.link_counts_min.articleobject, optional- The minimum number of outbound links in the article section of a page, for each link type:
follow,nofollow,sponsored, andugc. A saved opportunity with no link minimum has nolink_counts_min. opportunity.filters.link_counts_min.navobject, optional- The same, for the navigation section of a page.
opportunity.filters.link_counts_min.commentsobject, optional- The same, for the comments section of a page.
opportunity.similarity_targetstring- What the pages must be semantically similar to:
none,campaign, orsimilarity_text. Empty when it is not set. opportunity.similarity_textstring- The text of
similarity_targetsimilarity_text. Empty when it is not set. opportunity.vector_readybooltruewhen the vector of thesimilarity_textof the saved opportunity is made.opportunity.title_querystring- The words the title must have. Empty when it is not set.
opportunity.body_querystring- The words the body must have. Empty when it is not set.
opportunity.title_body_joinstring- How
title_queryandbody_queryare combined:andoror. Empty when it is not set.
Example
Request
curl -X POST https://api.oppalerts.com/v1/campaigns/saved_opportunity_add \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"campaign": 124,
"label": "Media kits naming boutique hotels",
"search": "opportunity_type",
"opportunity_type": "advertising/advertise-with-us",
"type_score_min": 40,
"similarity_target": "campaign",
"similarity_score_min": 25,
"title_query": "\"media kit\" OR advertise",
"pr_domain_min": 20
}'
Response
The response is shown in full.
{
"opportunity": {
"id": 12,
"label": "Media kits naming boutique hotels",
"state": "active",
"search": "opportunity_type",
"opportunity_type": "advertising/advertise-with-us",
"content_type": "",
"filters": {
"type_score_min": 40,
"similarity_score_min": 25,
"pr_domain_min": 20,
"pr_domain_max": 80,
"pr_host_min": 10,
"pr_host_max": 90,
"prot_domain_min": 5,
"prot_domain_max": 95,
"prot_host_min": 5,
"prot_host_max": 95,
"link_counts_min": {
"article": {
"follow": 2,
"nofollow": 1,
"sponsored": 0,
"ugc": 0
},
"nav": {
"follow": 1,
"nofollow": 0,
"sponsored": 0,
"ugc": 0
},
"comments": {
"follow": 0,
"nofollow": 1,
"sponsored": 0,
"ugc": 0
}
}
},
"similarity_target": "campaign",
"similarity_text": "",
"vector_ready": false,
"title_query": "\"media kit\" OR advertise",
"body_query": "",
"title_body_join": ""
}
}
The example call and the example answer are the contract samples, copied as they are. The answer shows every key of a saved opportunity, so it has values that the call did not send.
Errors
An error has an HTTP status and a JSON body with error, the error code, and error_description, the message. An example: a call with a token that does not have the scope api:write. This answer also has a WWW-Authenticate header with error="insufficient_scope" and the scopes that the call needs.
HTTP/1.1 403 Forbidden
WWW-Authenticate: Bearer error="insufficient_scope", scope="api:read api:write", resource_metadata="https://api.oppalerts.com/.well-known/oauth-protected-resource/v1", error_description="This token cannot change data. Make a new API token with edit permissions on the API tokens page, or connect the app again and allow changes."
Content-Type: application/json
{
"error": "forbidden",
"error_description": "This token cannot change data. Make a new API token with edit permissions on the API tokens page, or connect the app again and allow changes."
}
The error codes of this tool, each with its HTTP status and its sentence:
bad_param(HTTP 400): A parameter is missing, unknown, or has a wrong value. The sentence names it.no_campaign(HTTP 404): That campaign is not in this account.forbidden(HTTP 403): This token cannot change data. Make a new API token with edit permissions on the API tokens page, or connect the app again and allow changes.no_access(HTTP 403): You have read permissions for this campaign.db_error(HTTP 500): The change could not be saved. Nothing was changed.missing_field(HTTP 400): label is empty: send the name of the saved opportunity.bad_search(HTTP 400): search, opportunity_type, or content_type does not name a search or a type that exists. The sentence names the field.similarity_text_words(HTTP 400): similarity_text has more than 1,000 words: shorten it.type_limit(HTTP 409): Not saved: this campaign already has the most active opportunity types its plan allows. Archive a type before adding another.active_opportunity_limit(HTTP 409): Not saved: this campaign has the most active saved opportunities that its plan allows: 7 on the free plan, 25 on the other plans. The sentence gives the number. Archive one before you add or activate another.label_taken(HTTP 409): This campaign already has an opportunity with that label.similarity_text_too_long(HTTP 400): Not saved: the similarity text is too long to use in a search. Shorten it and save again.embed_failed(HTTP 502): Not saved: the similarity text could not be prepared for searching now. Nothing was changed. Try again in a few minutes.opportunity_limit(HTTP 409): This campaign has the most saved opportunities it can hold.similarity_text_empty(HTTP 400): similarity_target is similarity_text, and similarity_text is not sent or holds only spaces. Send the text, or choose another similarity_target.nothing_to_search(HTTP 400): similarity_target is none and there is no title_query and no body_query: a saved opportunity needs a vector, words, or both.query_no_term(HTTP 400): title_query or body_query holds no search term, such as only spaces, or only characters that are not letters or digits. The sentence names the field. Send at least one word or a phrase in quotes, or leave the field out.query_too_many_terms(HTTP 400): title_query or body_query holds more than 20 words or phrases. The sentence names the field and the limit. Send 20 or fewer: nothing is cut.query_operator(HTTP 400): title_query or body_query has a formatting error: a character that is not a letter, a digit, a space, or a search operator, or a search operator in a wrong place, for example parentheses inside parentheses, OR with no word on one side, or only words with - before them. The sentence names the field, says that the query has a formatting error, and says what the error is. The query is not saved.min_above_max(HTTP 400): A PR or PRoT minimum is above its maximum, for example pr_domain_min above pr_domain_max. The sentence names the 2 fields.rank_out_of_range(HTTP 400): A PR field is outside its range (a minimum 0 to 100, a maximum 1 to 100), or a PRoT field is outside its range (a minimum 0 to 1000000, a maximum 1 to 1000000). The sentence names the field and its range.
Limits
- This tool has its own daily count for the account. When the count is used up, the call is refused with
daily_limit(HTTP 429). account_calls_left shows the calls left today and when the count resets. - A refused call does not use the daily count of this tool.
- This tool is not an index search. It does not use the daily count of index searches.
- Only one change runs at a time per account. A call made while another change is running for the account is refused with
one_at_a_time(HTTP 429) and uses no daily call. Send it again after a few seconds. - The plan sets how many saved opportunities a campaign can hold (
opportunity_limit), and how many opportunity types can be active in a campaign (type_limit). - A campaign can have at most 7 active saved opportunities on the free plan, and 25 on the other plans (
active_opportunity_limit). similarity_text: at most 1,000 words and at most 20,000 characters.title_queryandbody_query: at most 500 characters each. At most 20 words or phrases each. A text with more is refused withquery_too_many_terms, and nothing is cut.
Same tool in MCP
The MCP tool is campaigns_saved_opportunity_add. See campaigns_saved_opportunity_add in MCP.