# Update Deal

Update Deal

Endpoint: POST /deals/{id}
Version: 2.0

## Path parameters:

  - `id` (integer, required)
    id

## Header parameters:

  - `Content-Type` (string, required)
    Content-Type

  - `Cookie` (string, required)
    Cookie

## Request body:

  - `application/json` (unknown)
    Note: The owner type and ID cannot be altered once the deal has been created.

## Request fields (application/json):

  - `bill_type` (string)
    Bill recipient when creating a deal
    Enum: "EXCHANGE", "NONE", "PUBLISHER"

  - `channels` (array)
    List of advertising channel IDs to associate with this deal (use GET /channels to see available channels)
    Example: [5,4]

  - `deal_identifier` (string)
    the identifier used within a bid request to reference the deal

  - `deal_type` (string)
    When updating deal to type `PG`, `price_type` must be set to `FIXED` and valid `start_datetime` and `end_datetime` must be present.
    Enum: "PG", "STANDARD"

  - `description` (string)
    the description of the deal

  - `end_datetime` (string)
    string / timestamp as full RFC 3339 date strings including timezone offsets: YYYY-MM-DDTHH:MM:SSZ or YYYY-MM-DDTHH:MM:SS-##:##

  - `name` (string)
    the name of the deal

  - `permissions` (object)
    List of entities that are allowed to target this deal, which should be either the owner entity or sub-entities of the owner entity. if a higher-level entity is included, then do not include any lower-level entity that is part of the included higher level entity. for example, if an organization X is listed in this parameter, then automatically all agencies and advertisers that are part of the organization X will be included and listing any such agencies and advertisers part of organization X will cause a validation error.

  - `permissions.advertiser_ids` (array)

  - `permissions.agency_ids` (array)

  - `permissions.all_organizations` (boolean, required)

  - `permissions.organization_ids` (array)

  - `price` (object)
    price floor or fixed value to use in auction along with the associated currency code

  - `price.currency_code` (string)
    3-letter currency code

  - `price.value` (string)
    Maximum is $9,999,999.9999

  - `price_type` (string)
    The deal is a "FLOOR" price deal (bids must be above this floor, and will likely clear above this floor) or "FIXED" price deal (bids must be at this price or above, and will clear at the fixed price)
    Enum: "FIXED", "FLOOR"

  - `start_datetime` (string)
    string / timestamp as full RFC 3339 date strings including timezone offsets: YYYY-MM-DDTHH:MM:SSZ or YYYY-MM-DDTHH:MM:SS-##:##

  - `status` (boolean)
    whether the deal is active

  - `sub_supply_source_id` (integer)
    the id of the publisher if the supply_source_id is set to 83 (BidSwitch)

  - `supply_source_id` (integer)
    the exchange providing the deal

  - `publisher_id` (integer)
    the publisher id (optional)

## Response 200 fields (application/json):

  - `data` (object)

  - `data.bill_type` (string)
    Who will be billed for the deal
    Enum: "EXCHANGE", "NONE", "PUBLISHER"

  - `data.channels` (array)
    List of advertising channels associated with this deal

  - `data.channels.id` (integer)
    Channel ID

  - `data.channels.name` (string)
    Channel name

  - `data.created_on` (string)

  - `data.deal_identifier` (string)
    ID used within a bid request to reference the deal

  - `data.deal_type` (string)
    deal_type is the type of deal. PG is for a Programmatic Guaranteed deal, and STANDARD is the only other value allowed
    Enum: "PG", "STANDARD"

  - `data.description` (string)
    Description of the deal

  - `data.end_datetime` (string)
    string / timestamp as full RFC 3339 date strings including timezone offsets: YYYY-MM-DDTHH:MM:SSZ or YYYY-MM-DDTHH:MM:SS-##:##

  - `data.entity_type` (string)
    Enum: "deal"

  - `data.id` (integer)
    ID of the deal

  - `data.name` (string)
    Name of the deal

  - `data.owner` (object)
    Level of ownership for the deal (i.e. who can edit the deal) and the id of the ownership entity. for example, if the ownership level is set to ADVERTISER, anyone with access to such advertiser can edit this deal.

  - `data.owner.id` (integer)

  - `data.owner.type` (string)
    Enum: "ADVERTISER", "AGENCY", "INTERNAL", "ORGANIZATION"

  - `data.permissions` (object)
    List of entities that are allowed to target this deal. if a higher-level entity is included, then do not include any lower-level entity that is part of the included higher level entity. for example, if an organization X is listed in this parameter, then automatically all agencies and advertisers that are part of the organization X will be included and listing any such agencies and adevertisers part of organization X will cause a validation error.

  - `data.permissions.advertiser_ids` (array)

  - `data.permissions.agency_ids` (array)

  - `data.permissions.all_organizations` (boolean)

  - `data.permissions.organization_ids` (array)

  - `data.price` (object)

  - `data.price.currency_code` (string)
    3-character ISO 1427 currency code

  - `data.price.value` (string)
    Maximum value is $9,999,999.9999

  - `data.price_method` (string)
    CPM is the only acceptable value for now
    Enum: "CPM"

  - `data.price_type` (string)
    The deal is a "FLOOR" price deal (bids must be above this floor, and will likely clear above this floor) or "FIXED" price deal (bids must be at this price or above, and will clear at the fixed price)
    Enum: "FIXED", "FLOOR"

  - `data.start_datetime` (string)
    string / timestamp as full RFC 3339 date strings including timezone offsets: YYYY-MM-DDTHH:MM:SSZ or YYYY-MM-DDTHH:MM:SS-##:##

  - `data.status` (boolean)
    Whether the deal is active

  - `data.sub_supply_source_id` (integer)
    ID of the publisher if the supply_source_id is set to 83 (BidSwitch)

  - `data.supply_source_id` (integer)
    Exchange providing the deal

  - `data.supply_source` (object)
    Supply source details

  - `data.supply_source.id` (integer)
    Supply source ID

  - `data.supply_source.name` (string)
    Supply source name

  - `data.publisher_id` (integer)
    Publisher ID

  - `data.publisher` (object)
    Publisher details

  - `data.publisher.id` (integer)
    Publisher ID

  - `data.publisher.name` (string)
    Publisher name

  - `data.strategies_count` (integer)
    Number of strategies targeting this deal

  - `data.organization_id` (integer)
    Organization ID that owns this deal

  - `data.impressions` (integer)
    Number of impressions

  - `data.effective_status` (string)
    Current effective status of the deal
    Enum: "ready", "creating", "ssp_status_mismatch", "ssp_start_date_mismatch", "ssp_end_date_mismatch", "organization_contract_start_date_error", "organization_contract_end_date_error", "organization_inactive", "agency_inactive", "advertiser_inactive", "campaign_inactive", "campaign_start_date_error", "campaign_end_date_error", "campaign_pg_flag_error", "strategy_inactive", "strategy_start_date_error", "strategy_end_date_error", "strategy_pg_flag_error", "strategy_concept_inactive", "creative_inactive", "deal_status_inactive", "deal_start_date_error", "deal_end_date_error", "strategy_not_assigned"

  - `data.severity` (integer)
    Severity level

  - `data.deal_groups` (array)
    Deal groups associated with this deal

  - `data.deal_groups.id` (integer)
    Deal group ID

  - `data.deal_groups.name` (string)
    Deal group name

  - `data.updated_on` (string)

  - `data.has_strategies` (boolean)
    Indicates if the deal has strategies assigned

  - `meta` (object)

  - `meta.status` (string)

## Response 400:

  - `400` (unknown)
    Reasons may include:
* "deal_type", "unsupported feature, cannot change deal_type from " + db_deal_type + " to " + request_deal_type
* '{}' format is invalid".format(field)
* 'deal_type' field is not present in db, requires manually investigations
* end_datetime is required and must match the dates in the __ Programmatic Guaranteed agreement
* Entities in the 'permissions' field must be equivalent to or sub-entities of the owner entity
* Invalid currency_code
* Invalid owner.id
* Invalid sub_supply_source_id
* missing owner
* overlap error: duplicate advertiserID
* overlap error: duplicate agencyID
* Owner type not found.
* 'owner.id' is a required property for this owner.type
* 'permissions.advertiser_ids' field must be present
* 'permissions.agency_ids' field must be present
* 'permissions.organization_ids' currently can have up to one id
* 'permissions.organization_ids' field must be present
* 'price.value' is invalid
* Programmatic guaranteed deals must have a fixed price
* start_datetime is required and must match the dates in the " + name + " Programmatic Guaranteed agreement
* 'start_datetime' must be earlier than 'end_datetime'
* 'sub_supply_source_id' is not necessary for this supply source
* 'sub_supply_source_id' is required for this supply source
* This deal_identifier already exists
* This supply source does not support programmatic guaranteed deals
* Unauthorized to set 'permissions.all_organizations' to true
* Unauthorized to set this 'owner.type'

