openapi: 3.0.3
info:
  description: This is the API for managing MNP on +Portability
  version: 1.2.0
  title: MNP +Portability API
  termsOfService: http://swagger.io/terms/
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
tags:
  - name: Mobile portabilities
    description: Get info about portabilities
  - name: Mobile operations
    description: Manage portabilities
servers:
  # Public Servers
  - url: https://mas-portability.sta.masstack.com/v1
    description: STA
  - url: https://mas-portability.masstack.com/v1
    description: PROD
paths:
  /orgs/{orgs}/portabilities:
    get:
      tags:
        - Mobile portabilities
      summary: Get portabilities info
      description: 'Returns a list of portabilities'
      operationId: getPortabilities
      parameters:
        - in: path
          name: orgs
          description: Tenant
          schema:
            type: string
          required: true
        - in: query
          name: filter
          description: Add filter to get portabilites
          schema:
            type: string
          required: false
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Portability'
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
    post:
      tags:
        - Mobile operations
      summary: Create portability request
      description: 'Create portability request'
      operationId: requestPortability
      parameters:
        - in: path
          name: orgs
          description: Tenant
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PortabilityRequest'
        required: true
      responses:
        '201':
          description: Created
        '204':
          description: No Content
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
  /orgs/{orgs}/portabilities/processId/{processId}:
    get:
      tags:
        - Mobile portabilities
      summary: Get portabilities by processId
      description: 'Returns a list of portabilities filter by processId'
      operationId: getPortabilitiesByProcessId
      parameters:
        - in: path
          name: orgs
          description: Tenant
          schema:
            type: string
          required: true
        - in: path
          name: processId
          description: ProcessId
          schema:
            type: string
          required: true
        - in: query
          name: filter
          description: Add filter to get portabilites
          schema:
            type: string
          required: false
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Portability'
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
  /orgs/{orgs}/portabilities/msisdn/{msisdn}:
    get:
      tags:
        - Mobile portabilities
      summary: Get portabilities by msisdn
      description: 'Returns a list of portabilities filter by msisdn'
      operationId: getPortabilitiesByMsisdn
      parameters:
        - in: path
          name: orgs
          description: Tenant
          schema:
            type: string
          required: true
        - in: path
          name: msisdn
          description: Msisdn
          schema:
            type: string
          required: true
        - in: query
          name: filter
          description: Add filter to get portabilites
          schema:
            type: string
          required: false
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Portability'
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
  /orgs/{orgs}/portabilities/msisdn/{msisdn}/last:
    get:
      tags:
        - Mobile portabilities
      summary: Get last portabilities by msisdn
      description: 'Returns last portability from a msisdn'
      operationId: getLastPortabilitiesByMsisdn
      parameters:
        - in: path
          name: orgs
          description: Tenant
          schema:
            type: string
          required: true
        - in: path
          name: msisdn
          description: Msisdn
          schema:
            type: string
          required: true
        - in: query
          name: filter
          description: Add filter to get portabilites
          schema:
            type: string
          required: false
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Portability'
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
  /orgs/{orgs}/portabilities/id/{id}:
    get:
      tags:
        - Mobile portabilities
      summary: Get portabilities by id
      description: 'Returns a portability'
      operationId: getPortabilityDetailById
      parameters:
        - in: path
          name: orgs
          description: Tenant
          schema:
            type: string
          required: true
        - in: path
          name: id
          description: id
          schema:
            type: string
          required: true
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PortabilityDetail'
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
  /orgs/{orgs}/portabilities/pendingDonor:
    get:
      tags:
        - Mobile portabilities
      summary: Get pending donor portabilities
      description: 'Returns a list of portability pending response'
      operationId: getPendingDonorPortabilities
      parameters:
        - in: path
          name: orgs
          description: Tenant
          schema:
            type: string
          required: true
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Portability'
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
  /orgs/{orgs}/portabilities/{processId}/accept:
    post:
      tags:
        - Mobile operations
      summary: Accept donor portability
      description: 'Accept donor portability'
      operationId: acceptPortability
      parameters:
        - in: path
          name: orgs
          description: Tenant
          schema:
            type: string
          required: true
        - in: path
          name: processId
          description: ProcessId would be accept
          schema:
            type: string
          required: true
      responses:
        '201':
          description: Created
        '204':
          description: No Content
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
  /orgs/{orgs}/portabilities/{processId}/deny:
    post:
      tags:
        - Mobile operations
      summary: Deny donor portability
      description: 'Deny donor portability'
      operationId: denyPortability
      parameters:
        - in: path
          name: orgs
          description: Tenant
          schema:
            type: string
          required: true
        - in: path
          name: processId
          description: ProcessId would be deny
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DenyPortability'
      responses:
        '201':
          description: Created
        '204':
          description: No Content
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
  /orgs/{orgs}/ownerOperator/{msisdn}:
    get:
      tags:
        - Mobile operations
      summary: Get the phonenumber owner
      description: 'Return the operator owner'
      operationId: getOwnerOperatorByMsisdn
      parameters:
        - in: path
          name: orgs
          description: Tenant
          schema:
            type: string
          required: true
        - in: path
          name: msisdn
          description: Msisdn
          schema:
            type: string
          required: true
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OwnerOperator'
        '404':
          description: Not Found
        '500':
          description: Internal Server Error
  /orgs/{orgs}/operator:
    get:
      tags:
        - Mobile portabilities
      summary: Get filtered info for operators in Central Node
      description: 'Returns the filtered info saved from operators in Central Node'
      operationId: getOperators
      parameters:
        - in: path
          name: orgs
          description: Tenant
          schema:
            type: string
          required: true
        - in: query
          name: operator
          description: Operator
          schema:
            type: string
          required: false
        - in: query
          name: operatorCode
          description: Operator code
          schema:
            type: string
          required: false
        - in: query
          name: status
          description: Operator status
          schema:
            type: string
          required: false
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/OperatorConfigs'
        '404':
          description: Not Found
        '500':
          description: Internal Server Error
  /orgs/{orgs}/portabilities/{processId}/restartReply:
    post:
      tags:
        - Mobile operations
      summary: Restart reply of a donor portability
      description: 'Reset the response of a portability before portability window'
      operationId: restartReply
      parameters:
        - in: path
          name: orgs
          description: Tenant
          schema:
            type: string
          required: true
        - in: path
          name: processId
          description: Process id
          schema:
            type: string
          required: true
      responses:
        '201':
          description: Created
        '204':
          description: No Content
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
  /orgs/{orgs}/portabilities/{msisdn}/cancel:
    post:
      tags:
        - Mobile operations
      summary: Cancel a portability
      description: 'Cancel a portability'
      operationId: cancel
      parameters:
        - in: path
          name: orgs
          description: Tenant
          schema:
            type: string
          required: true
        - in: path
          name: msisdn
          description: Msisdn
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DenyPortability'
      responses:
        '201':
          description: Created
        '204':
          description: No Content
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
components:
  schemas:
    PortabilityRequest:
      required:
        - access_type
        - contract_code
        - msisdn_ranges
        - nrn_receptor
      properties:
        access_type:
          type: string
          enum: [INDIVIDUAL,MULTIPLE,MIXED]
          description: >
            Access type of the request. Must be one of these values: [INDIVIDUAL,MULTIPLE,MIXED]
          example: INDIVIDUAL
        contract_code:
          type: string
          description: Contract signed by subscriber
          example: "00528902840"
        external_reference:
          type: string
          description: External identifier
          example: "PORTIN_902840_634443633"
        msisdn_ranges:
          type: array
          items:
            $ref: '#/components/schemas/MsisdnRanges'
          description: List of phone number ranges to port
        nrn_receptor:
          type: string
          pattern: "^[\\d]{6,6}$"
          description: Network Routing Number of recipient operator. Must match pattern '^[\\d]{6,6}$'
          example: "741111"
        recipient_operator:
          type: string
          pattern: "^[\\d]{3,3}$"
          description: Receiving operator code. Must match pattern '^[\\d]{3,3}$'
          example: null
        subscriber:
          $ref: '#/components/schemas/Subscriber'
        subscriber_request_date:
          type: string
          description: Date of the portability request. Timestamp in UTC time zone, format yyyy-MM-ddTHH:mm:ssZ
          example: "2022-02-24T13:45:10Z"
        window_date:
          type: string
          description: Window date of the portability. Timestamp in UTC time zone, format yyyy-MM-ddTHH:mm:ssZ
          example: null
    DenyPortability:
      type: object
      properties:
        cause:
          type: string
    Portability:
      type: object
      properties:
        access_type:
          type: string
        cause_status:
          type: string
        contract_code:
          type: string
        create_date_nc:
          type: string
        donor_operator:
          type: string
        external_reference:
          type: string
        icc_id:
          type: string
        id:
          type: string
        message_type:
          type: string
        msisdn:
          type: string
        nrn_receptor:
          type: string
        process_id:
          type: string
        recipient_operator:
          type: string
        recipient_rol:
          type: boolean
        state:
          type: string
        tenant:
          type: string
        window_date:
          type: string
    PortabilityDetail:
      type: object
      properties:
        access_type:
          type: string
        cause_status:
          type: string
        contract_code:
          type: string
        create_date_nc:
          type: string
        donor_operator:
          type: string
        id:
          type: string
        message_type:
          type: string
        msisdn:
          type: string
        nrn_receptor:
          type: string
        portability_events:
          type: object
          properties:
            account:
              $ref: '#/components/schemas/PortabilityEvent'
        process_id:
          type: string
        recipient_operator:
          type: string
        recipient_rol:
          type: boolean
        state:
          type: string
        subscriber:
          type: object
          properties:
            account:
              $ref: '#/components/schemas/Subscriber'
        tenant:
          type: string
        window_date:
          type: string
    PortabilityEvent:
      type: object
      properties:
        cause_status:
          type: string
        event_date:
          type: string
        id:
          type: string
        message_type:
          type: string
        notification_code:
          type: string
        process_id:
          type: string
        recipient_rol:
          type: string
    MsisdnRanges:
      type: object
      required:
        - initial_range
      properties:
        initial_range:
          $ref: '#/components/schemas/MsisdnInfo'
        end_range:
          $ref: '#/components/schemas/MsisdnInfo'
    MsisdnInfo:
      type: object
      required:
        - msisdn
      properties:
        msisdn:
          $ref: '#/components/schemas/PhoneNumber'
        icc_id:
          type: string
          pattern: "^[0-9A-Za-z]{19,20}$"
          description: Line identifier. Must match pattern '^[0-9A-Za-z]{19,20}$'
          example: "8934221507160508791"
    PhoneNumber:
      type: object
      required:
        - number
      properties:
        country_code:
          type: string
          pattern: "^[\\d]{1,3}$"
          description: Country code, without the '+'. Must match pattern '^[\\d]{1,3}$'
          example: "34"
        number:
          type: string
          pattern: "^[\\d]{4,14}$"
          description: Phone number inside the national network. Must match pattern '^[\\d]{4,14}$'
          example: "634443633"
    Subscriber:
      type: object
      properties:
        addresses:
          type: array
          items:
            $ref: '#/components/schemas/Address'
          description: Subscriber addresses information
        document:
          type: string
          description: Identity document number
          example: "09288205T"
        document_type:
          type: string
          enum: [NIF,DNI,CIF,NIE,PASSPORT,TR]
          description: >
            Identity document type. Must be one of these values: [NIF,DNI,CIF,NIE,PASSPORT,TR]
          example: NIF
        id:
          type: string
          description: Subscriber id
          example: null
        email:
          type: string
          description: Subscriber email
          example: null
        msisdn:
          $ref: '#/components/schemas/PhoneNumber'
        name:
          type: string
          description: Subscriber name
          example: Martina
        nationality:
          type: string
          example: España
          description: Subscriber nationality
        second_name:
          type: string
          description: Subscriber second name
          example: null
        surname:
          type: string
          description: Subscriber surname
          example: Fraile Méndez
    Address:
      type: object
      description: Address details
      properties:
        address:
          type: string
          description: Name of street, road, avenue...
          example: "Calle Leonardo Prieto, 8"
        city:
          type: string
          description: Address city
          example: Madrid
        country:
          type: string
          description: Address country
          example: Spain
        postal_code:
          type: string
          description: Address zipcode
          example: "28040"
        province:
          type: string
          description: Address province
          example: Madrid
        type:
          type: string
          enum: [BILLING,INSTALLATION,CONTACT]
          description: >
            Type of address. Must be one of these values: [BILLING,INSTALLATION,CONTACT]
          example: CONTACT
    OwnerOperator:
      type: object
      properties:
        msisdn:
          type: string
        nrn:
          type: string
        codigoOperadorActual:
          type: string
        codigoOperadorPropietarioRango:
          type: string
        involucradaProcesoPortabilidad:
          type: boolean
        portada:
          type: boolean
        codigoReferenciaSolicitudPortabilidadMovil:
          type: string
        codigoReferenciaIncidencia:
          type: array
          items:
            type: string
    OperatorConfigs:
      type: array
      items:
        "$ref": "#/components/schemas/OperatorConfig"
    OperatorConfig:
      type: "object"
      properties:
        id:
          type: integer
          description: Operator Config id
          format: int64
          example: 4
        operator:
          type: string
          maxLength: 255
          description: The operator name
          example: YOIGO
        operator_code:
          type: string
          maxLength: 3
          description: The operator code
          example: "005"
        nrn_range:
          "$ref": "#/components/schemas/OperatorRangeNrns"
        network_operator:
          type: string
          maxLength: 3
          description: Network operator code
          example: "003"
        msisdn_range:
          "$ref": "#/components/schemas/OperatorRangeMsisdns"
        individual_quota:
          type: string
          maxLength: 1
          description: Character representing the group of maximum daily individual portability requests the operator belongs to.
          example: A
        multiple_quota:
          type: integer
          maximum: 99
          description: Maximum daily number of multiple portability requests allowed by the operator.
          example: 50
        change_quota:
          type: integer
          maximum: 999999999
          description: Maximum daily number of changes allowed by the operator as donor rol.
          example: 1000
        status:
          type: string
          maxLength: 32
          enum: [ ACTIVO,DESHABILITADO,ALTA_EXTRAORDINARIA ]
          description: >
            Operator status. Must be in: [ACTIVO,DESHABILITADO,ALTA_EXTRAORDINARIA]
          example: ACTIVO
        status_date:
          type: string
          format: date-time
          description: Operator status change date
          example: "2024-01-30T10:00:00Z"
        backup:
          type: boolean
          description: Whether the entry is backed up or not.
          example: false
    OperatorRangeNrns:
      type: array
      items:
        "$ref": "#/components/schemas/OperatorRangeNrn"
    OperatorRangeNrn:
      type: object
      description: Operator config range of Network Routing Numbers
      properties:
        id:
          type: integer
          description: The range id
          format: int64
        initial_nrn:
          type: string
          maxLength: 6
          description: Initial value of the range
          example: 900053
        final_nrn:
          type: string
          maxLength: 6
          description: Final value of the range
          example: 900056
    OperatorRangeMsisdns:
      type: array
      items:
        "$ref": "#/components/schemas/OperatorRangeMsisdn"
    OperatorRangeMsisdn:
      type: object
      description: Operator config range of msisdns
      properties:
        id:
          type: integer
          description: The range id
          format: int64
        initial_msisdn:
          type: string
          maxLength: 9
          description: Initial value of the range
          example: 600000000
        final_msisdn:
          type: string
          maxLength: 9
          description: Final value of the range
          example: 600000001
externalDocs:
  description: Find out more about Swagger
  url: http://swagger.io

