create_campaign
Create new advertising campaigns for Uber with configurable settings including budget, schedule, objectives, and status to manage ad promotions effectively.
Instructions
Create a new campaign
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ad_account_id | Yes | The ad account UUID | |
| auth_token | No | Bearer token for authentication | |
| campaign_data | Yes |
Implementation Reference
- src/index.ts:594-621 (handler)The primary handler function for the 'create_campaign' tool. It validates inputs using Zod schemas, constructs the API URL, sends a POST request to the Uber Ads API to create a campaign, and returns the response or handles errors.private async createCampaign(args: any) { const authToken = this.getAuthToken(args.auth_token); const adAccountId = AdAccountIdSchema.parse(args.ad_account_id); const campaignData = CampaignCreateSchema.parse(args.campaign_data); const url = `${UBER_ADS_API_BASE_URL}/${adAccountId}/campaigns`; try { const response = await axios.post(url, campaignData, { headers: { 'Authorization': `Bearer ${authToken}`, 'Accept': 'application/json', 'Content-Type': 'application/json', }, }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return this.handleApiError(error); } }
- src/index.ts:32-40 (schema)Zod validation schema used in the createCampaign handler to parse and validate the campaign_data input.const CampaignCreateSchema = z.object({ name: z.string().min(1, 'Campaign name is required'), status: z.enum(['ACTIVE', 'PAUSED']).default('ACTIVE'), budget_type: z.enum(['DAILY', 'LIFETIME']).default('DAILY'), budget_amount: z.number().positive('Budget amount must be positive'), start_time: z.string().optional(), end_time: z.string().optional(), objective: z.enum(['AWARENESS', 'CONSIDERATION', 'CONVERSION']).default('CONVERSION'), });
- src/index.ts:211-270 (registration)Tool registration in the listTools response, including name, description, and detailed inputSchema matching the handler's expectations.name: 'create_campaign', description: 'Create a new campaign', inputSchema: { type: 'object', properties: { auth_token: { type: 'string', description: 'Bearer token for authentication', }, ad_account_id: { type: 'string', description: 'The ad account UUID', }, campaign_data: { type: 'object', properties: { name: { type: 'string', description: 'Campaign name', }, status: { type: 'string', enum: ['ACTIVE', 'PAUSED'], default: 'ACTIVE', description: 'Campaign status', }, budget_type: { type: 'string', enum: ['DAILY', 'LIFETIME'], default: 'DAILY', description: 'Budget type', }, budget_amount: { type: 'number', minimum: 0.01, description: 'Budget amount in USD', }, start_time: { type: 'string', description: 'Campaign start time (ISO 8601)', }, end_time: { type: 'string', description: 'Campaign end time (ISO 8601)', }, objective: { type: 'string', enum: ['AWARENESS', 'CONSIDERATION', 'CONVERSION'], default: 'CONVERSION', description: 'Campaign objective', }, }, required: ['name', 'budget_amount'], additionalProperties: false, }, }, required: ['ad_account_id', 'campaign_data'], additionalProperties: false, }, },
- src/index.ts:418-419 (registration)Dispatcher switch case in the CallToolRequestSchema handler that routes calls to the createCampaign method.case 'create_campaign': return await this.createCampaign(args);